如何将搜索表单仅添加到商店页面和类别页面
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 条件标记的详细信息
相关文章:
- 在html Select中添加搜索
- 使用单个文本框向多个字段添加严格搜索
- jqgridnavgrid在搜索按钮和自定义按钮之后添加按钮
- 如何将搜索表单仅添加到商店页面和类别页面
- 将图像添加到 json 搜索栏
- Angular ng sortable-如果我在一个栏中添加了一个搜索框,则拖放在两列之间无法正常工作
- jQuery脚本,它搜索现有的查询参数并且不添加“"如果存在
- Javascript:在内部站点中添加搜索功能
- 如何在jquery移动中添加搜索按钮
- 如何在填充选择下拉列表中添加搜索筛选器
- 如何在流星待办事项应用程序示例中添加搜索
- 如何添加搜索,例如按类别
- 如何在嵌入式SoundCloud播放器上添加搜索
- 如何在加载应用程序之前添加搜索功能
- 我如何添加搜索到一个揭示.js演示文稿
- 向选择列表添加搜索选项
- 如何正确地添加搜索查询参数,以url包含哈希在javascript
- 向url添加搜索条件,但不能返回
- 通过JavaScript添加搜索栏
- Ext.js:如何在面板头部添加搜索栏