Categories in Custom Post Type Loop/List
I’ve created a custom post type and everything is working beautifully…almost. I have managed to set tags and categories for my custom post type, they show up in the admin panel, they save and everything seems great. Just like a regular post.
Where I’m now stuck is how to display these items in my loop or post. For example, with a regular blog post, you can put your meta data to show “posted in” or “filed under” (terminology up to the user) and then a sequence of category links. For example: Filed Under: Beauty / Fashion / Editorials
While my categories and tags save with each new custom post type, I cannot for the life of me figure out how to publish it so that either in my list or in the actual post itself, I can have something like:
ABC Logo (title of post)
Thumbnail (featured image)
Branding / Digital / Print (the categories and/or in which this falls under)
Here is the code that sits in the functions.php file and as I said, it’s all working great. I just cannot find anything online (I’ve spent the entire day searching) for how to simply display the categories and tags within your custom post type (either in list or single view).
register_taxonomy( 'works', 'portfolio', array( 'label' => __('Portfolio Categories'), 'singular_label' => __('Portfolio Category'), 'hierarchical' => true, 'query_var' => true, 'rewrite' => true, 'show_in_nav_menus' => true, ) ); // took out author and custom fields register_post_type('portfolio', array( 'label' => __('Portfolio'), 'singular_label' => __('Work'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => true, 'query_var' => true, 'show_in_nav_menus' => true, 'menu_position' => 3, 'taxonomies' => array('post_tag', 'category'), 'supports' => array('title', 'editor', 'thumbnail', 'category'), register_post_type('portfolio', $args), '_builtin' => false, // It's a custom post type, not built in! ));
Unfortunately my site is local while I build it out. This is the last remaining thing for me to figure out.
I look forward to any and all responses!
- The topic ‘Categories in Custom Post Type Loop/List’ is closed to new replies.