2013-02-12 59 views
0

只是想询问是否有人在这里可以告诉我如何将目前的产品类别名称在Woocommerce单一产品页面的顶部。包括在woocommerce单品页面顶部的当前的产品类别名称?

我会想将它放置在导航条上面我的产品页面的顶部。我在此处包含了一个链接,指向我在此处查找的示例:http://www.espguitars.com/guitars/signature/kirk.html -

请注意,在页面右上角您会看到当前类别名称,在这种情况下,类别名字是吉他。我意识到,我已经给了该网站的例子是不是一个WordPress站点,但我觉得一定有办法与woocommerce做到这一点。

+0

这必须是你要找的 https://gist.github.com/mikejolley/3206230我粘贴它'functions.php',在注释编辑线33喜欢和它的作品。 – espidesigns 2013-04-26 08:31:23

回答

2

如果您检查WooCommerce插件的“templates/single-product”文件夹中的meta.php文件,您将看到WooCommerce插件如何将当前产品的产品类别显示为产品元信息。

<?php 
... 
global $post, $product; 
?> 
<div class="product_meta"> 
... 
<?php echo $product->get_categories(', ', '<span class="posted_in">' . _n('Category:', 'Categories:', sizeof(get_the_terms($post->ID, 'product_cat')), 'woocommerce') . ' ', '.</span>'); ?> 
... 
</div> 

请将代码复制到您的主题并进行相应的修改。

相关问题