1
我正在使用Wordpress & Woocommerce &有一个商店页面和我卖的产品的几个类别页面。我想将搜索表单()添加到标题,但仅限于这些页面。我确定这与if(is_shop())命令有关,我需要将其添加到标题中,但是我对php/javascript不太了解,因此我需要帮助你了不起的人?那么,如何才能让搜索栏仅显示在商店页面,类别页&结帐页面标题中,而不是主页,我的帐户页面等?如何将搜索表单添加到商店页面和类别页面?
HTML(header.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>
正是我一直在寻找谢谢!但是我在哪里把它放在标题中?因为当我在endif之后添加它时;声明,该网站崩溃。 –
@TAA:我已经更新了代码。它只需要php标签封装。现在就试试。 – zipkundan
还要确保在if语句的结尾php标记之后添加此代码。即在新行('endif;?>')之后。 – zipkundan