template_include перестанет работать над обновлением woocommerce - PullRequest
0 голосов
/ 25 апреля 2018

Следующий код предназначен для переопределения шаблона страницы «Сведения о продукте». Он работал с момента последнего обновления WooCommerce. Может ли кто-нибудь помочь мне в этом, спасибо заранее.

    add_filter('template_include', 'wpautomate_plugin_templates');
    function wpautomate_plugin_templates( $template )
    {   
        $plugin_path='';
        $reflector = new ReflectionClass('Ze_Single_Product_Layout');
        $file_name=plugin_dir_path($reflector->getFileName());
        $plugin_path=$file_name;
        $post_types = array('product');
        $template_id=get_post_meta( get_the_ID(), '_product_layout', true );
        if (is_singular('product') && !empty($template_id))
        {
            //render custom template  for single product
            $template = $plugin_path . 'template/woo-single-page.php';
        }
        return $template;           

    }//end of function

1 Ответ

0 голосов
/ 26 апреля 2018

Вам нужно вызвать этот фильтр

add_filter('template_include', 'wpautomate_plugin_templates');

с init action hook

add_action('init','load_custom_template_woo');
function load_custom_template_woo(){
  add_filter('template_include', 'wpautomate_plugin_templates');
}

Спасибо

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...