Support » Fixing WordPress » I want to intermingle custom post types and posts more closely

  • I am working on a web site where we have both regular posts, and a custom post type for events. The “events” post type is fantastic, and I love it, as it contains all sorts of extra fields for date, location, RSVP list, etc. etc.

    However, my problem is that I want event post types to be more closely linked to regular posts, for my users. This means that I would like to have:

    – categories for my event post types, that are identical to the categories for my regular posts (if they could share the same taxonomy/categories, I feel like that would be the most convenient from a site-management perspective, but from an underlying-structure perspective that may be asking too much or introducing other problems.).

    – category pages that include event post types along with regular posts.

    – search results that include both event post types and regular posts.

    This seems like a tall order, and like it somehow is antithetical to the custom post type idea.

    I’d appreciate any guidance or thoughts on how to make this work. If you do this sort of work for hire, I would be happy to follow up further.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Add this to the functions.php file in your theme folder. This will list events anywhere posts are listed (assuming the name of your custom post type is “event”).

    add_filter( 'pre_get_posts', 'my_get_posts' );
    function my_get_posts( $query ) {
    	if ( is_home() && $query->is_main_query() )
    		$query->set( 'post_type', array( 'post', 'event' ) );
    	return $query;

    via Justin Tadlock

    Thank you very much to the tip, Felix! I will give it a try.

    I’m thinking this will work awesomely for me on the front page of the site and possibly in searches. Do you know how it affects taxonomies and category pages?

    At any rate I am excited to check it out. Take care.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘I want to intermingle custom post types and posts more closely’ is closed to new replies.