Using HeadSpace with Custom Post Types

I frequently install HeadSpace, the WordPress SEO plugin by John Godley, when I work on a WordPress site.

Recently I have been making use of the new custom post type features of WordPress 3.0 but found that the HeadSpace meta box for editing the title and description tags did not show on my custom post type edit screens.

After a bit of delving through the code I figured out the way to do this – note that this may only work if your custom post type uses the default post capabilities.

It checks that the HeadSpace class is available and if so adds the meta box to your custom post type edit screen. Just add the following code into your plugin or theme’s functions.php file replacing ‘myposttype’ with your custom post type.

/**
 * Add Headspace plugin support for myposttype
 */
function myposttype_headpspace_add_custom_box() {
 
	global $headspace2;
 
	if ( function_exists( 'add_meta_box' ) && is_object( $headspace2 ) ) {
		add_meta_box( 'headspacestuff', __('HeadSpace', 'headspace'), array( &$headspace2, 'metabox' ), 'myposttype', 'normal', 'high' );
	}
 
}
add_action( 'wp_print_scripts', 'myposttype_headpspace_add_custom_box' );
cosmetic dentist los angeles
pure green coffee bean
 

Ben Huson