I often want to create a custom post type with an accompanying sidebar. For example, a Lessons sidebar that only displays on Lessons and Programs (a related taxonomy). Here is a simple plugin that does just that, or provides a basis for customization. You can also copy the code into your functions.php
file directly.
View plugin code, or download plugin.
A couple of points to note:
The plugin some Genesis features to the Lessons post type. Comment out the features you don’t need, or simply delete this block:
add_action( 'genesis_init', 'child_lessons_theme_supports' );
/*
* Add theme supports to Lessons
*/
function child_lessons_theme_supports() {
add_post_type_support( 'lesson', array(
'genesis-cpt-archives-settings', // Archive settings
'genesis-layouts', // In-post layout settings
'genesis-seo', // In-post SEO settings
'genesis-scripts', // In-post script options
) );
}
The plugin also removes the post meta and post info by default. If you want these, delete this block of code:
add_action( 'genesis_before', 'child_remove_lesson_meta', 11 );
/*
* Remove post info and meta for Lessons
*/
function child_remove_lesson_meta() {
// Remove post info
remove_post_type_support( 'lesson', 'genesis-entry-meta-before-content' );
// Remove post meta
remove_post_type_support( 'lesson', 'genesis-entry-meta-after-content' );
}
Hope you find it useful 🙂