douyin9987 2015-10-25 14:25
浏览 155
已采纳

product-archives.php文件中的Woocommerce(shop)标题

I read that it is possible to place alternative header into woocommerce pages using get_header('shop'); in product-archives.php template in my custom theme. In order to make it work I need to make copy of header.php file and rename it to header-shop.php. It should be also located in same folder as header.php file. Unfortunately I can't get this to work. Anything I am missing if somebody notices that would be great help.

  • 写回答

2条回答 默认 最新

  • dpwqicw157673 2015-10-26 05:56
    关注

    You can have a work around.

    1. Just make a copy of header.php in your current theme with the same name (i.e. header.php).
    2. Create another copy of the header.php with you desired name(i.e. header-shop.php).
    3. Now you just need to add a custom code in header.php at the starting lines to check that whether its a product archive page(using this function http://codex.wordpress.org/Function_Reference/is_post_type_archive), if yes then include the header-shop.php else show the below default code of the file itself.

    An Example Snippet:

    if ( is_post_type_archive('product')) {
         // Load header-shop.php
    }else{
         // continue with default code
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失