Adding Custom Post Types to Genesis WordPress Framework

Although I have heard about it for years, I am relatively new to the Genesis framework for WordPress. More than anything, I think that I was afraid of choosing the wrong framework when it came to comparing Genesis to Thesis to myriad others.

It turns out that it's difficult to be wrong when it comes to choosing a framework, because they make your life easier – whichever one you choose! I ultimately chose the Genesis framework because I was intrigued with the $349.95 developer pack that they offer and figure that it will come in handy in many places. Plus, as I get familiar with the framework, I envision the need to move many current and future sites to a common platform and framework. Side Note: ironically I did not choose Genesis for Jeffalytics, even though it was an option at the time. I might be kicking myself in the future.

Genesis was installed in a breeze and I selected the Associate theme to begin my project, because it was the closest to what I needed to recreate in my design.

* One note of advice – make sure that you install both the genesis theme as well as your selected child theme when working with Genesis. Even though you are only activating one theme, the genesis folder needs to reside in your themes folder in order to provide benefit to child theme. If you don't follow this tip and only upload your child theme, it simply won't work.

For the most part, I am content with the way that the Associate theme works out of the box, but there were definitely some items that needed to be changed. The first was enabling all 2 and 3 column genesis layouts for the site. This can be done by going into your child themes functions.php file and removing the following lines:

/** Unregister 3-column site layouts */
genesis_unregister_layout( ‘content-sidebar-sidebar' );
genesis_unregister_layout( ‘sidebar-sidebar-content' );
genesis_unregister_layout( ‘sidebar-content-sidebar' );

While there very well may be a purpose to disable these columns for this layout, they are very much needed for what I am trying to accomplish. Of course, in order for these layouts to render properly, you will need to do some serious hacks to your style.css file, but that's what theme customization is all about, right?

Next, I need to add several custom post types to the site in order to meet the requirements for this site. While this task may seem daunting, it's actually quite easy using the standard WordPress code for registering a custom post type, combined with a tweak to make it work properly with the Genesis layout.

For this example, I wanted to make a post type simply called video so that videos could be uploaded to the site with their own custom layout, metadata and other information.

/** Add Custom Post Types */

add_action( ‘init', ‘create_post_type' );
function create_post_type() {
register_post_type( ‘the_video',
array(
‘labels' => array(
‘name' => __( ‘Videos' ),
‘singular_name' => __( ‘Video' )
),
‘public' => true,
‘has_archive' => true,
‘rewrite' => array(‘slug' => ‘videos'),
)
);
}

/**
* add Genesis layout options to custom posts types
*
* @author Brian Lis
* @link http://dev.studiopress.com/genesis-layout-options-for-custom-post-types.htm
*/

add_post_type_support( ‘the_video', ‘genesis-layouts' );

Tip: make sure the post type name is not ambiguous or a reserved word in WordPress, or else you might run into a conflict that causes your blog to stop functioning.

Thanks to Brian Lis at StudioPress for the Genesis specific code.

There you have it – custom post types in Genesis, plugged in to the available layout options.

Next up? More learning of Genesis, and hopefully more sharing on this blog!

Leave a Comment

Your email address will not be published. Required fields are marked *

Price Lock Alert: Save $1000 on Lifetime Access To Academy Insiders

00
Months
00
Days
00
Hours
00
Minutes
00
Seconds
Scroll to Top