skip to Main Content

I have a navbar that I only want to appear on the product category page on my woocommerce site. Does anybody know what php or javascript code I need to make this happen? Thanks in advance!

HTML of the navbar (currently in the index.php file)

<nav class="navbar navbar-inverse" data-spy="affix" data-offset-top="91" id="search-nav"></nav>

Note: I’m using WordPress, Woocommerce and Twitter Bootstrap

2

Answers


  1. You could make a custom header with your navbar and then call it on the category-page template like this:

    <?php get_header( 'your-custom-header' ); ?>
    
    Login or Signup to reply.
  2. WooCommerce provides the is_product_category() conditional to check if the user is viewing a product category archive page:

    <?php if( is_product_category() ): ?>
    
        <nav class="navbar navbar-inverse" data-spy="affix" data-offset-top="91" id="search-nav"></nav>
    
    <?php endif; ?>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search