首页 文章

所有WooCommerce文件的页面模板

提问于
浏览
0

我有一个页面模板,它是我主题中的最小化页面(称为min-page.php) . 我用它来删除页眉和页脚信息并添加一些基本链接,这样客户就不会分心 .

我可以在各种WooCommerce页面(结帐,购物车,我的帐户)的页面属性中更改此模板,但我无法在产品页面或显示所有产品的一般购物页面上更改它 .

如何设置这些页面以使用我的页面模板?

1 回答

  • 0

    您可以通过 functions.php 使用以下代码更改单个产品模板

    function get_product_template($single_template) {
     global $post;
    
     if ($post->post_type == 'product') {
          $single_template = dirname( __FILE__ ) . '/min-page.php';
     }
     return $single_template;
    }
    add_filter( 'single_template', 'get_product_template' );
    

    放置代码后检查模板路径 .

相关问题