admin管理员组文章数量:1417043
I am building a movie site, here is the codes to get the taxonomies
function display_post_taxonomies( $content ) { if( is_single() ) { $args = array( 'public' => true, '_builtin' => false ); $output = 'objects'; $operator = 'and'; $taxonomies = get_taxonomies( $args, $output, $operator ); if( $taxonomies ) { $content .= ''; foreach( $taxonomies as $taxonomy ) { $args = array( 'orderby' => 'name', 'echo' => false, 'taxonomy' => $taxonomy->name, 'title_li' => '' . __( $taxonomy->labels->name, 'your-themes-text-domain' ) . '', 'show_option_none' => __( 'No ' . $taxonomy->labels->name, 'your-themes-text-domain' ) ); $content .= '
- ' . wp_list_categories( $args ) . '
The first $args
is generic to display all not built in taxonomies, but I want to exclude couple of taxonomies but I couldn't
If I want to show just one taxonomy I'll use this code
$args = array( 'name' => 'actors');
So I've tried the following codes but it didn't work
$args = array( 'name' => array( 'actors', 'directors', 'musicians' ) );
How can I do it? Thanks in advance.
I am building a movie site, here is the codes to get the taxonomies
function display_post_taxonomies( $content ) { if( is_single() ) { $args = array( 'public' => true, '_builtin' => false ); $output = 'objects'; $operator = 'and'; $taxonomies = get_taxonomies( $args, $output, $operator ); if( $taxonomies ) { $content .= ''; foreach( $taxonomies as $taxonomy ) { $args = array( 'orderby' => 'name', 'echo' => false, 'taxonomy' => $taxonomy->name, 'title_li' => '' . __( $taxonomy->labels->name, 'your-themes-text-domain' ) . '', 'show_option_none' => __( 'No ' . $taxonomy->labels->name, 'your-themes-text-domain' ) ); $content .= '
- ' . wp_list_categories( $args ) . '
The first $args
is generic to display all not built in taxonomies, but I want to exclude couple of taxonomies but I couldn't
If I want to show just one taxonomy I'll use this code
$args = array( 'name' => 'actors');
So I've tried the following codes but it didn't work
$args = array( 'name' => array( 'actors', 'directors', 'musicians' ) );
How can I do it? Thanks in advance.
Share Improve this question asked May 22, 2013 at 17:30 Rahman SharifRahman Sharif 3331 gold badge4 silver badges15 bronze badges1 Answer
Reset to default 0I believe your error is in the if ( $taxonomies )
statement, I believe you want if ( is_taxonomy( $taxonomy ); )
see this link for further usages.
I'm not at home so I can't test this, but I think the option you present should work, as mentioned here.
$args = array(
'name' => array( 'actors', 'directors', 'musicians' )
);
And I think you should also remove the .
from $content .= '';
making it $content = '';
, this error repeats itself 3x.
I would also like to know, when you use the code $args = array( 'name' => 'actors');
does the code perform as intended?
本文标签: custom taxonomyHow to get multiple Taxonomies not All Taxonomies
版权声明:本文标题:custom taxonomy - How to get multiple Taxonomies not All Taxonomies? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745265075a2650550.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论