我已经将标签云小部件作为元素包含在我的博客帖子中。有没有可能让标签云只显示分配给给定帖子的相关标签?
谢谢!
发布于 2018-02-08 09:52:09
与其使用标签云小部件,我建议编辑您的single.php (最好是在子主题中),以包含post标签meta。您可以使用类似以下内容的内容:
function tags_after_single_post_content($content) {
if( is_singular('post') && is_main_query() ) {
$tags = the_tags('<div class="entry-meta">Tagged with: ',' • ','</div><br />');
$content .= $content . $tags;
}
return $content;
}
add_filter( 'the_content', 'tags_after_single_post_content' );它可能会根据您的主题而有所不同。
发布于 2020-07-04 01:17:53
您可以创建和使用快捷代码
function my_tags_shortcode( $atts ) {
global $product;
echo wc_get_product_tag_list( $product->get_id(), ', ', '<span class="tagged_as">' . _n( 'Tag:', 'Tags:', count( $product->get_tag_ids() ), 'woocommerce' ) . ' ', '</span>' );
}
add_shortcode( 'my_tags_shortcode', 'my_tags_shortcode');然后,您可以在帖子或页面中的任何位置使用短码[my_tags_shortcode]。
https://stackoverflow.com/questions/48674338
复制相似问题