Warning: Trying to access array offset on false in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 216
the_taxonomies() - 显示包含可用选项的文章分类 - WordPress函数 - WordPress动力
当前浏览:首页 / WordPress函数 / the_taxonomies()

the_taxonomies( array $args = array() )

显示包含可用选项的文章分类


Warning: Undefined array key -1 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 185

Warning: Undefined array key 2 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 186

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "377a794e343579ac7010272f30912e1a" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "0644722bfef668bcde651d8ae516cfc1" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "da3fa25e51008d111052e4f7cd1619a4" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

taxmore...

taxonomy 分类法more...

themore...


描述

此函数可以在循环内用于显示文章的分类(taxonomy),而无需指定文章ID。您也可以在循环外使用它来显示特定文章的分类。


参数

$args

(array)(可选) 关于使用哪个文章以及如何格式化输出的参数。除以下参数外,还共享get_the_taxonomies()支持的所有参数。

  • 'post'
    (int|WP_Post) 文章ID或对象以获取分类。默认当前文章。
  • 'before'
    (string) 显示在分类之前。默认空字符串。
  • 'sep'
    (string) 分隔每个分类。默认值为空格。
  • 'after'
    (string) 在分类后显示。默认空字符串。

默认值: array()



源码

查看源码 官方文档


更新日志

版本描述
2.5.0开始引入

使用示例

  • 示例1

    这可以在主题中使用,以轻松支持所有分类。

    <footer class="entry-footer">
    <?php the_taxonomies( array(
    			'before' => '<div class="tax-link-wrap">',
    			'template' => '<span class="taxonomy-label">%s:</span> <span class="taxonomy-term-list">%l.</span>',
    			'term_template' => '<a href="%1$s" rel="tag">%2$s</a>',
    			'sep' => '<br />',
    			'after' => '</div>',
    		) ); ?>
    </footer>
    
  • 示例2

    实例

    // Arguments as a query-string.
    the_taxonomies( 'before=<ul>&after=</ul>' ); 
     
    <?php
    // Arguments as an array.
    $args = array(
    	'before' => '<p class=\"meta\">',
    	'after'  => '<p class=\"meta\">',
    );
    the_taxonomies( $args );