• Resolved nospario

    (@nospario)


    Hi,

    I am using the BLANK Theme 1 by Chris Coyier.

    I”ve created some categories, ‘cars’, ‘ford’, ‘mondeo’ etc etc

    I have used the Custom Post Type UI plugin to create a custom post type of Vehicles. I’ve ticked the Built-in Taxonomies Categories box when doing this.

    I have then created a single-vehicles.php template and an archive-vehicles.php template.

    I have then created a post using the Vehicles custom post type and assigned the post to a couple of categories.

    I have then used the category widget to produce a dropdown of my categories. When I select from these categories I am taken to the original archive page (archive.php) and not my new archive-vehicles.php template and my post is not displayed.

    Any ideas anyone?

    Many thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Custom post types are not included in the regular post loop. If you have a regular category for default post types, your custom post types will not show up there. If you want to display custom and non-custom posts on the same page, you could try a tag archive instead of a category archive, and you could use a Custom Menu to change the link.

    Thread Starter nospario

    (@nospario)

    I don’t want to show them on the same page, I want the custom posts to show up in the custom template, which does work if I browser directly to the post, but when selecting from the category drop down that doesn’t.

    I don’t understand why I can assign a custom post to a particular category but then when using the category widget drop down it doesn’t take me to it, even though the post count in the drop down shows that it is picked up.

    Thread Starter nospario

    (@nospario)

    Okay, I get it. The custom posts are associated with the categories but when clicking on the dropdown that is retrieving normal posts and not the custom posts.

    Right. If you click your “normal” category link it will only show posts that are the default post type. It will not show custom posts. You can also take a look at the code I posted here:

    https://tri.be/show-your-events-in-the-main-post-loop/

    It worked for me! You can change is_archive() || is_tag() || is_home() to whichever templates you want your custom posts to show up on.

    Otherwise you can use a Custom Menu or create a template that will query your custom posts when the link is clicked (if you only want the custom posts). It gets dicey when you have a category and a custom post type that have the same name and slug. You may have to use the IDs instead.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom Post Type Archive and Single Templates’ is closed to new replies.