Html code is not showing in woocommerce shop page on adding in header.php?

I have added some code in header.php but it is not showing in shop page. It is showing all other pages.if( is_home() ||

I have added some code in header.php but it is not showing in shop page. It is showing all other pages.

      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="/">Appetizers & Snacks</a>
<a class="cat_button" href="/">Fillers International</a>
<a class="cat_button" href="/">Meals and More</a>
<a class="cat_button" href="/">Mains Indian</a>
<a class="cat_button" href="/">Mains Oriental</a>
<a class="cat_button" href="/">Mains International</a>
<a class="cat_button" href="/">Desserts And Drinks</a>
 </div>
    <div class = "row">';
} ?>

This is my code and I added the lines <div class="tab1"> <a class="cat_button" href="/">Appetizers & Snacks</a> <a class="cat_button" href="/">Fillers International</a> <a class="cat_button" href="/">Meals and More</a> <a class="cat_button" href="/">Mains Indian</a> <a class="cat_button" href="/">Mains Oriental</a> <a class="cat_button" href="/">Mains International</a> <a class="cat_button" href="/">Desserts And Drinks</a> </div>

This tab class is showing in all pages excepts shop page, category page, product page.

I have added some code in header.php but it is not showing in shop page. It is showing all other pages.

      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/product-category/appetizers-snacks/">Appetizers & Snacks</a>
<a class="cat_button" href="https://packnchew/product-category/fillers-international/">Fillers International</a>
<a class="cat_button" href="https://packnchew/product-category/meals-more/">Meals and More</a>
<a class="cat_button" href="https://packnchew/product-category/mains-indian/">Mains Indian</a>
<a class="cat_button" href="https://packnchew/product-category/mains-oriental/">Mains Oriental</a>
<a class="cat_button" href="https://packnchew/product-category/mains-international/">Mains International</a>
<a class="cat_button" href="https://packnchew/product-category/desserts-drinks/">Desserts And Drinks</a>
 </div>
    <div class = "row">';
} ?>

This is my code and I added the lines <div class="tab1"> <a class="cat_button" href="https://packnchew/product-category/appetizers-snacks/">Appetizers & Snacks</a> <a class="cat_button" href="https://packnchew/product-category/fillers-international/">Fillers International</a> <a class="cat_button" href="https://packnchew/product-category/meals-more/">Meals and More</a> <a class="cat_button" href="https://packnchew/product-category/mains-indian/">Mains Indian</a> <a class="cat_button" href="https://packnchew/product-category/mains-oriental/">Mains Oriental</a> <a class="cat_button" href="https://packnchew/product-category/mains-international/">Mains International</a> <a class="cat_button" href="https://packnchew/product-category/desserts-drinks/">Desserts And Drinks</a> </div>

This tab class is showing in all pages excepts shop page, category page, product page.

Share Improve this question asked Jul 6, 2019 at 10:44 Shobha PatwalShobha Patwal 13 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

Can you use WooCommerce conditional tags instead of the default? For example, if you want this block of content to appear for all pages, use is_woocommerce() or if it should only appear on the main shop page, use is_shop().

For example:

if( is_woocommerce() ){
    //echo your content here...
} ?>

Source: https://docs.woocommerce/document/conditional-tags/

 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/product-category/appetizers-snacks/">Appetizers & Snacks</a>
<a class="cat_button" href="https://packnchew/product-category/fillers-international/">Fillers International</a>
<a class="cat_button" href="https://packnchew/product-category/meals-more/">Meals and More</a>
<a class="cat_button" href="https://packnchew/product-category/mains-indian/">Mains Indian</a>
<a class="cat_button" href="https://packnchew/product-category/mains-oriental/">Mains Oriental</a>
<a class="cat_button" href="https://packnchew/product-category/mains-international/">Mains International</a>
<a class="cat_button" href="https://packnchew/product-category/desserts-drinks/">Desserts And Drinks</a>
 </div>
    <div class = "row">';
} ?>

Check out very first line,

if( is_home() || ! $ed_section || ! ( is_front_page() || is_page_template( 'template-home.php' ) ) ){

The code inside that block is for Home Front page only. If you want that to work on all pages, I will recommend you to put above that or include woocommerce in the if statement as well.

Good Luck.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745341062a4623327.html

相关推荐

  • Html code is not showing in woocommerce shop page on adding in header.php?

    I have added some code in header.php but it is not showing in shop page. It is showing all other pages.if( is_home() ||

    3小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信