admin管理员组文章数量:1130349
I have created custom post type with 'members'
<?php
$member = new CPT(array(
'post_type_name' => 'members',
'singular' => __('Members', 'c2s'),
'plural' => __('Members', 'c2s'),
'slug' => 'Members'
),
array(
'supports' => array('title', 'editor', 'thumbnail', 'comments'),
'menu_icon' => 'dashicons-groups'
));
$member->register_taxonomy(array(
'taxonomy_name' => 'members_tags',
'singular' => __('Members Tag', 'c2s'),
'plural' => __('Members Tags', 'c2s'),
'slug' => 'member-tag'
));
?>
I am trying to print/display members_tags into the individual post.
I have created custom post type with 'members'
<?php
$member = new CPT(array(
'post_type_name' => 'members',
'singular' => __('Members', 'c2s'),
'plural' => __('Members', 'c2s'),
'slug' => 'Members'
),
array(
'supports' => array('title', 'editor', 'thumbnail', 'comments'),
'menu_icon' => 'dashicons-groups'
));
$member->register_taxonomy(array(
'taxonomy_name' => 'members_tags',
'singular' => __('Members Tag', 'c2s'),
'plural' => __('Members Tags', 'c2s'),
'slug' => 'member-tag'
));
?>
I am trying to print/display members_tags into the individual post.
Share Improve this question asked Aug 3, 2017 at 6:24 Rabin RaiRabin Rai 11 silver badge2 bronze badges 1- Possibly using the WP Custom Post Type Class which is now PostTypes by Joe Grainger – admcfajn Commented Nov 9, 2018 at 7:09
1 Answer
Reset to default 2You can use get_the_term_list() to output a list of links:
<?php echo get_the_term_list( get_the_ID(), 'members_tags', '', ',' ); ?>
That will output a comma-separated list of links to attached member_tags.
If you want the raw tags so you have more control over HTML, use get_the_terms()
<?php $member_tags = get_the_terms( get_the_ID(), 'members_tags' ); ?>
I have created custom post type with 'members'
<?php
$member = new CPT(array(
'post_type_name' => 'members',
'singular' => __('Members', 'c2s'),
'plural' => __('Members', 'c2s'),
'slug' => 'Members'
),
array(
'supports' => array('title', 'editor', 'thumbnail', 'comments'),
'menu_icon' => 'dashicons-groups'
));
$member->register_taxonomy(array(
'taxonomy_name' => 'members_tags',
'singular' => __('Members Tag', 'c2s'),
'plural' => __('Members Tags', 'c2s'),
'slug' => 'member-tag'
));
?>
I am trying to print/display members_tags into the individual post.
I have created custom post type with 'members'
<?php
$member = new CPT(array(
'post_type_name' => 'members',
'singular' => __('Members', 'c2s'),
'plural' => __('Members', 'c2s'),
'slug' => 'Members'
),
array(
'supports' => array('title', 'editor', 'thumbnail', 'comments'),
'menu_icon' => 'dashicons-groups'
));
$member->register_taxonomy(array(
'taxonomy_name' => 'members_tags',
'singular' => __('Members Tag', 'c2s'),
'plural' => __('Members Tags', 'c2s'),
'slug' => 'member-tag'
));
?>
I am trying to print/display members_tags into the individual post.
Share Improve this question asked Aug 3, 2017 at 6:24 Rabin RaiRabin Rai 11 silver badge2 bronze badges 1- Possibly using the WP Custom Post Type Class which is now PostTypes by Joe Grainger – admcfajn Commented Nov 9, 2018 at 7:09
1 Answer
Reset to default 2You can use get_the_term_list() to output a list of links:
<?php echo get_the_term_list( get_the_ID(), 'members_tags', '', ',' ); ?>
That will output a comma-separated list of links to attached member_tags.
If you want the raw tags so you have more control over HTML, use get_the_terms()
<?php $member_tags = get_the_terms( get_the_ID(), 'members_tags' ); ?>
本文标签: How to display custom post type tags
版权声明:本文标题:How to display custom post type tags? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749195748a2330948.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论