如何将搜索表单仅添加到商店页面和类别页面


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

我正在使用Wordpress和Woocommerce,并且有一个商店页面和我销售的产品的一些类别页面。我想将搜索表单()添加到标题中,但仅限于这些页面。我确定这与我需要添加到标头中的 if (is_shop()) 命令有关,但我不太擅长 php/javascript,因此我寻求你们这些了不起的人的帮助?!那么,如何让搜索栏只显示在商店页面、类别页面和结帐页面标题上,而不是主页、我的帐户页面等?

HTML(标头.php文件):

<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>
<?php    
if( is_shop() || is_product_category() || is_checkout() ){
   get_search_form();
}
?>

有关 wooCommerce 条件标记的详细信息