WordPress 显示所有自定义分类法名称

WordPress 开发评论166阅读模式

有时需要显示网站主题与插件创建的所有自定义分类法名称,会用到下面的代码:

<?php
	$args = array(
	  'public'   => true,
	  '_builtin' => false
	   
	); 
	$output = 'names'; // or objects
	$operator = 'and'; // 'and' or 'or'
	$taxonomies = get_taxonomies( $args, $output, $operator );
	if ( $taxonomies ) {
		echo '<ul>';
		foreach ( $taxonomies  as $taxonomy ) {
			echo '<li>' . $taxonomy . '</li>';
		}
		echo '</ul>';
	}
?>

 

本站文章大部分始于原创,用于个人学习记录,可能对您有所帮助,仅供参考!

weinxin
我的微信
版权声明
本站原创文章转载请注明文章出处及链接,谢谢合作!
 
知更鸟
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

拖动滑块以完成验证