[wp-hackers] Adding field(s) before Title and post content on custom post type

Mike Schinkel mikeschinkel at newclarity.net
Sat Jul 17 05:08:31 UTC 2010


On Jul 16, 2010, at 5:50 PM, Mohammad Jangda wrote:
>> For that matter I'd also like to see plugins be able to add new "supports"
>> features for custom post types with a register_post_type_support() or
>> similar.
> 
> I might be misreading what you want, but plugins can already add support for
> custom features using add_post_type_support:
> 
> <?php
> add_action( 'init', 'post_type_support_test' );
> 
> function post_type_support_test() {
> 
> echo '<p>Do Posts support Authors? ' . ( post_type_supports( 'post',
> 'author' ) ? 'yes' : 'no' );
> 
> echo '<p>Do Posts support Pancakes? ' . ( post_type_supports( 'post',
> 'pancakes' ) ? 'yes' : 'no' );
> 
> add_post_type_support( 'post', 'pancakes' );
> 
> echo '<p>Do Posts support Pancakes <em>now</em>? ' . ( post_type_supports(
> 'post', 'pancakes' ) ? 'yes' : 'no' );
> }
> ?>

True.  I was thinking of something more integrated, i.e. consider a site about movies, I might want to add an "actors" supports functionality:

register_post_type('movie',
	array(
		'label'        => 'Movie',
		'public'       => true,
		'show_ui'      => true,
		'query_var'    => 'movie',
		'supports'     => array(
			'title',
			'editor',
			'thumbnail',
			'actors',
		)
);

Yes, I can currently add "actors" to the list of supports, but nothing happens if I do.  And yes I can also cobble together various functionality that would emulate the support that we each might expect, i.e. a metabox, loading and saving the data, etc..  I was just expressing that it would be nice if inclusion of "actors" could automatically call an API to add "support" for actors. Aside from simplicity for the implementor one big potential benefit is greater robustness; the saving hooks are called in many contexts and if not written very carefully can have unexpected data corrupting side-effects in other contexts.

Earth-shattering functionality? No, just a small but nice evolution from where we are today.

-Mike


More information about the wp-hackers mailing list