标签列表由特定类别 - wordpress制成

Nil*_*s_e 6 wordpress tag-cloud categories

这个功能是否内置于wordpress中?我没有在食品法典中看到任何东西.

codex.wordpress.org/Function_Reference/wp_tag_cloud

我有一些特定于类别的页面,我想显示与这些帖子相关的所有标签.

我确实找到了这个,但我不确定它是否正确或是否存在更好的方法(来源)(旧方法!!!!):

<?php
    query_posts('category_name=html');
    if (have_posts()) : while (have_posts()) : the_post();
        $posttags = get_the_tags();
        if ($posttags) {
            foreach($posttags as $tag) {
                $all_tags_arr[] = $tag -> name;
            }
        }
    endwhile; endif; 

    $tags_arr = array_unique($all_tags_arr);
?>
    <ul>
<?php
    foreach($tags_arr as $tag){
        echo '<li>'.$tag.'</li>';
    }
?>
</ul>
<?php wp_reset_query(); ?>
Run Code Online (Sandbox Code Playgroud)

更新(简化):::

要从特定类别制作标签列表,这段代码要好得多(只需更改类别名称):

::由于循环错误,最近再次更新::

    <ul>
                <?php
                    query_posts('category_name=html');
                    if (have_posts()) : while (have_posts()) : the_post();

                        if( get_the_tag_list() ){
                            echo $posttags = get_the_tag_list('<li>','</li><li>','</li>');
                        }

                    endwhile; endif; 

                    wp_reset_query(); 
                ?>
</ul>
Run Code Online (Sandbox Code Playgroud)

即使很难我可能有一个解决方案,如果有新的解决方案请更新.

blu*_*noo 2

我认为您找到的方法是实现您想要的目标的唯一方法。也许你可以修改一些行,但这个概念是正确的。

目前我认为没有办法像使用核心 WordPress 功能一样过滤标签。