Site icon WP Smith

Genesis Specific: Add Genesis SEO and Layout Options to My Custom Post Type

Understanding WordPress Custom Post Types
So if you are running on the Genesis Framework, and you've created your new custom post type. So where are the SEO options!? Well, more than likely, you didn't add support for the Genesis SEO options to your custom post types. This feature alone makes Genesis so powerful and such an awesome Theme Framework. To add the Genesis SEO options only takes one additional support code, not even one line.

Wherever you registered your custom post type, add 'genesis-seo', 'genesis-layouts' to the support array. And there it is! Genesis SEO options are now available for your custom post type! (see sample example below).

If you do not have the registration code or the plugin does not allow you to add custom support features, no problem! Just use, add_post_type_support();. In your functions.php, add the following:
[php]
add_post_type_support( 'wps_cars', 'genesis-seo' );
add_post_type_support( 'wps_cars', 'genesis-layouts' );
[/php]

It would need to occur in the 'init' hook. So, in your functions.php, it will appear as:
[php]add_action('init', 'my_custom_init');

function my_custom_init() {
add_post_type_support( 'wps_cars', 'genesis-seo' );
add_post_type_support( 'wps_cars', 'genesis-layouts' );
}

[/php]

Sample Custom Post Type Registration with Genesis SEO Support

[php highlight="26"]add_action('init', 'wps_cpt_init');
function wps_cpt_init() {
$labels= array(
'name' => _x('Cars', 'post type general name'),
'singular_name' => _x('Car', 'post type singular name'),
'add_new' => _x('Add New', 'car'),
'add_new_item' => __('Add New Car'),
'edit_item' => __('Edit Car'),
'new_item' => __('New Car'),
'view_item' => __('View Car'),
'search_items' => __('Search Car'),
'not_found' => __('No cars found'),
'not_found_in_trash' => __('No cars found in Trash'),
'parent_item_colon' => '',
'menu_name' => 'Cars'
);
$args = array(
'labels' => $labels,
'public' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title','editor','author','thumbnail','genesis-seo')
);
register_post_type( 'wps_cars' , $args );
}[/php]