如何检查网页是woocommerce中的类别还是产品? [英] How to check if a page is category or product in woocommerce?
本文介绍了如何检查网页是woocommerce中的类别还是产品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在woocommerce.php
中使用is_category,但该方法不起作用.我想根据页面打印标题.
I'm trying to use is_category in woocommerce.php
which is not working. I want to print the title according the page.
如果页面是类别页面,则将打印woocommerce_page_title()
;如果页面是产品页面,则应打印the_title()
.
IF a page is category page then will print woocommerce_page_title()
and if a page is product then should print the_title()
.
我在woocommerce.php
中使用的代码是:
<?php if(is_category()){ ?>
<h1 class="page-title"><?php woocommerce_page_title(); ?></h1>
<?php }
else{
the_title();
}
?>
但是在每种情况下它都在打印the_title()
.我认为is_category()
不适用于woocommerce.
But in every case it is printing the_title()
. I think is_category()
is not working for woocommerce.
或者可以说出woocommerce如何打印类别和产品标题吗?
Or Can any one tell how woocommerce do it to print category and product title?
任何帮助将不胜感激.
推荐答案
您应该使用
is_product_category()
代替
is_category()
这篇关于如何检查网页是woocommerce中的类别还是产品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文