How do I add the search form to the shop page & category pages only?

I’m using WordPress & Woocommerce & have a shop page and a few category pages for the products I’m selling. I want to add the search form () to the header but only to these pages. I’m sure it’s got something to do with a if (is_shop()) command that I need to add to the header but I’m not really good with php/javascript therefore I enlist the help of you amazing people?! So, how do I get the search bar to only show up on the shop page, category pages & checkout page headers and NOT the home page, my account page, etc.?

HTML (the header.php file):

<div id="page" class="site">
  <a class="skip-link screen-reader-text" href="#main"><?php esc_html_e( 'Skip to content', 'devo' ); ?></a>

  <header id="masthead" class="site-header" role="banner">
    <div class="site-branding">

        <?php
        if ( is_front_page() && is_home() ) : ?>
            <img src="http://myimagefile">
            <!-- <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1> -->

        <?php else : ?>
            <img src="myimagefile">
            <!-- <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p> -->
        <?php
        endif;

        $description = get_bloginfo( 'description', 'display' );
        if ( $description || is_customize_preview() ) : ?>
            <p class="site-description"><?php echo $description; /* WPCS: xss ok. */ ?></p>
        <?php
        endif; ?>

    </div>
  </header>

Related posts

1 comment

Comments are closed.