【问题标题】:Page template for all WooCommerce Files所有 WooCommerce 文件的页面模板
【发布时间】:2017-05-16 20:39:42
【问题描述】:

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

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

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

【问题讨论】:

    标签: wordpress woocommerce


    【解决方案1】:

    您可以通过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' );
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-21
      • 2017-02-03
      • 2016-09-27
      • 2013-05-30
      • 1970-01-01
      相关资源
      最近更新 更多