Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#24812 closed enhancement (wontfix)

register_post_type should allow you to include posts in the main blog

Reported by: unknowndomain's profile unknowndomain Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description

When you create a Custom Post Type, there should be an argument like public etc... that allows your post type to be included in the main blog, just like post does.

This could be something like this:

'include_on_home_query' => true,

Example:

register_post_type( 'activity', array(
	'labels' => array(
		'name'               => __( 'Activities' ),
		'singular_name'      => __( 'Activity' ),
		'all_items'          => __( 'All Activities' ),
		'add_new_item'       => __( 'Add New Activity' ),
		'edit_item'          => __( 'Edit Activity' ),
		'new_item'           => __( 'New Activity' ),
		'view_item'          => __( 'View Activity' ),
		'search_items'       => __( 'Search Activities' ),
		'not_found'          => __( 'No Activities found' ),
		'not_found_in_trash' => __( 'No Activities found in Trash' )
	),
	'public' => true,
	'include_on_home_query' => true,
	'menu_position' => 5,
	'menu_icon' => plugin_dir_url(__FILE__) . 'icon.png',
	'supports' => array(
		'title',
		'editor',
		'thumbnail'
	),
	'register_meta_box_cb' => array( &$this, 'register_metabox' ),
	'taxonomies' => array(
		'year'
	),
	'has_archive' => true
) );

Change History (11)

#1 @johnbillion
11 years ago

  • Cc johnbillion added

#2 follow-up: @alexvorn2
11 years ago

Don't like the idea.

#3 in reply to: ↑ 2 @unknowndomain
11 years ago

Replying to alexvorn2:

Don't like the idea.

This comment isn't helpful, please provide details why you think it is a bad idea, i.e. what harm it would cause, or why it isn't useful.

The reason I brought it up, is because some CPTs need to be treated like 1st class citizens, they are essentially posts with extra options.

#4 @johnbillion
11 years ago

I think this has merit. I've used filters in the past to add CPTs into the main loop (which means they show up in feeds too).

#5 follow-up: @alexvorn2
11 years ago

I did not say it is a bad idea.
It is possible to join two post types and to display them on the main page with wp_query.

#6 in reply to: ↑ 5 @unknowndomain
11 years ago

Replying to alexvorn2:

I did not say it is a bad idea.
It is possible to join two post types and to display them on the main page with wp_query.

I am not quite clear how that would work, however as John says, it isn't impossible to do other ways, but this pretty small patch to core would make CPTs do something they've not easily done before.

#7 follow-up: @wonderboymusic
11 years ago

filter pre_get_posts - custom post types aren't really supposed to be "posts," I don't see this getting much support

If you want it to show up in your site’s main RSS feed, then it’s probably not a custom post type.

Last edited 11 years ago by wonderboymusic (previous) (diff)

#8 in reply to: ↑ 7 ; follow-up: @unknowndomain
11 years ago

Replying to wonderboymusic:

filter pre_get_posts - custom post types aren't really supposed to be "posts," I don't see this getting much support

If you want it to show up in your site’s main RSS feed, then it’s probably not a custom post type.

I don't know if I agree, whilst that post makes a convincing argument, the suggestion that every post you might every wish to post is covered by post formats is ludicrous, and a custom UI is often needed.

#9 @markoheijnen
11 years ago

Personally I don't see this in core too. I do change the post_type with the filter pre_get_posts but 'include_on_home_query' would not give me any control. Also mixing multiple post types in general is a bad idea.

#10 in reply to: ↑ 8 @c3mdigital
11 years ago

  • Keywords close added

Replying to unknowndomain:

Replying to wonderboymusic:

filter pre_get_posts - custom post types aren't really supposed to be "posts," I don't see this getting much support

If you want it to show up in your site’s main RSS feed, then it’s probably not a custom post type.

I don't know if I agree, whilst that post makes a convincing argument, the suggestion that every post you might every wish to post is covered by post formats is ludicrous, and a custom UI is often needed.

No one is saying that. For these cases you have the pre_get_posts_filter. This argument has been debated before, See: http://core.trac.wordpress.org/ticket/12702#comment:28

#11 @helen
11 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Closing per comments above - agree on using pre_get_posts.

Note: See TracTickets for help on using tickets.