Get Categories of a custom post type in single page
-
add_shortcode( ‘my_cat_list’, ‘my_list_categories_shortcode’ );
/**
* this function outputs your category list where you
* use the [my_cat_list] shortcode.
*/function my_list_categories_shortcode() {
global $post;
$post_id = $post->ID;$args = array(
‘orderby’ => ‘name’,
‘order’ => ‘ASC’,
‘style’ => ‘list’,
‘post_type’ => ‘projects’,
‘current_category’ => 0,
‘title_li’ => __( ‘Categories’ ),
‘show_option_none’ => __(‘No categories’),
‘taxonomy’ => ‘projects-category’
);return wp_list_categories($args);
}I am trying to get Only checked categories of a single post on detail page. This is showing all categories of CPT. If I supply post id it show nothing.
Please recommend.
- The topic ‘Get Categories of a custom post type in single page’ is closed to new replies.