在添加Header.php时,WooCommerce商店页面中没有显示HTML代码吗?

时间:2019-07-06 作者:Shobha Patwal

我在标题中添加了一些代码。php,但它不会显示在商店页面中。它正在显示所有其他页面。

      if( is_home() || ! $ed_section  || ! ( is_front_page()  || is_page_template( \'template-home.php\' ) ) ){
    echo \'<div class = "container"><div id="content" class="site-content">
<div class="tab1">
<a class="cat_button" href="https://packnchew.com/product-category/appetizers-snacks/">Appetizers & Snacks</a>
<a class="cat_button" href="https://packnchew.com/product-category/fillers-international/">Fillers International</a>
<a class="cat_button" href="https://packnchew.com/product-category/meals-more/">Meals and More</a>
<a class="cat_button" href="https://packnchew.com/product-category/mains-indian/">Mains Indian</a>
<a class="cat_button" href="https://packnchew.com/product-category/mains-oriental/">Mains Oriental</a>
<a class="cat_button" href="https://packnchew.com/product-category/mains-international/">Mains International</a>
<a class="cat_button" href="https://packnchew.com/product-category/desserts-drinks/">Desserts And Drinks</a>
 </div>
    <div class = "row">\';
} ?>
这是我的代码,我添加了行<div class="tab1"> <a class="cat_button" href="https://packnchew.com/product-category/appetizers-snacks/">Appetizers & Snacks</a> <a class="cat_button" href="https://packnchew.com/product-category/fillers-international/">Fillers International</a> <a class="cat_button" href="https://packnchew.com/product-category/meals-more/">Meals and More</a> <a class="cat_button" href="https://packnchew.com/product-category/mains-indian/">Mains Indian</a> <a class="cat_button" href="https://packnchew.com/product-category/mains-oriental/">Mains Oriental</a> <a class="cat_button" href="https://packnchew.com/product-category/mains-international/">Mains International</a> <a class="cat_button" href="https://packnchew.com/product-category/desserts-drinks/">Desserts And Drinks</a> </div>

此选项卡类显示在除店铺页面、类别页面、产品页面之外的所有页面中。

2 个回复
SO网友:Tom

是否可以使用WooCommerce条件标记而不是默认标记?例如,如果希望此内容块显示在所有页面上,请使用is_woocommerce() 或者,如果它只出现在主商店页面上,请使用is_shop().

例如:

if( is_woocommerce() ){
    //echo your content here...
} ?>
资料来源:https://docs.woocommerce.com/document/conditional-tags/

SO网友:Robin

 if( is_home() || ! $ed_section  || ! ( is_front_page()  || is_page_template( \'template-home.php\' ) ) ){
    echo \'<div class = "container"><div id="content" class="site-content">
<div class="tab1">
<a class="cat_button" href="https://packnchew.com/product-category/appetizers-snacks/">Appetizers & Snacks</a>
<a class="cat_button" href="https://packnchew.com/product-category/fillers-international/">Fillers International</a>
<a class="cat_button" href="https://packnchew.com/product-category/meals-more/">Meals and More</a>
<a class="cat_button" href="https://packnchew.com/product-category/mains-indian/">Mains Indian</a>
<a class="cat_button" href="https://packnchew.com/product-category/mains-oriental/">Mains Oriental</a>
<a class="cat_button" href="https://packnchew.com/product-category/mains-international/">Mains International</a>
<a class="cat_button" href="https://packnchew.com/product-category/desserts-drinks/">Desserts And Drinks</a>
 </div>
    <div class = "row">\';
} ?>
查看第一行,

如果(is\\u home()| |)$ed\\u节| |!(is\\u front\\u page()| | is\\u page\\u模板(\'template home.php\')){

该块中的代码仅用于首页。如果您希望在所有页面上都能做到这一点,我建议您在上面加上这一点,或者在If声明中也包括woocommerce。

祝你好运

相关推荐