Skip Navigation

[Closed] Getting custom post types to show up under Categories

This support ticket is created 11 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 3 replies, has 2 voices.

Last updated by dbarber 11 years, 6 months ago.

Assisted by: Mario.

Author
Posts
#10270

I've got a fairly basic question that I can't work out for myself and haven't been able to find an answer for here, so I thought I should ask for help.

I would like to display all of the categories for my Custom Post Types on the homepage and innerpage sidebars of a site I'm doing and, when clicked, I would like to have custom post types show up under the category with which they're associated.

I've tried, but no matter what, I'm coming up empty-handed.

Any idea as to what I'm missing / doing wrong?

Thanks

#10279

Okay, so I've mostly worked out the problem.

I dropped the following code from here <a href="hidden link"> into the custom-functions.php file of the theme I use (note: business-listing, in the code below, is the slug for my custom post type):

add_filter('pre_get_posts', 'query_post_type');
function query_post_type($query) {
if(is_category() || is_tag() || is_home() && empty( $query->query_vars['suppress_filters'] ) ) {
$post_type = get_query_var('post_type');
if($post_type)
$post_type = $post_type;
else
$post_type = array('post','business-listing','nav_menu_item');
$query->set('post_type',$post_type);
return $query;
}
}

...and now listings are showing up when I click on the category link.

The only problems now are that the category page isn't showing the category name on the page and the listing that displays is "a little" light on information.

It's just showing a linked business name and a "read more" link.

Any suggestions on how I can get the category title to show up on the page and how I might be able to get a little more info to display with the category page listings (basically any custom fields I created)?

Thanks

#10421

Dear Dbarber,

You have to customize your theme template:

category.php

Please let me know if there is anything else that I can assist you with.

Regards
Caridad

#10645

Hi Caridad

Thanks for the assistance.

PHP is not my thing so the category.php file for my theme is a mystery to me.

I've posted a thread on the theme's forum to see if they can help.

If not, I'll be back.

Either way, I'll post the outcome here.

Thanks again.

The topic ‘[Closed] Getting custom post types to show up under Categories’ is closed to new replies.