cropped-KTWD_Logo-InkBlue-1.jpg
  • Home
  • Services
  • Pricing
  • Process
  • Projects
  • About
  • Contact

How to create a Custom Post Type in Genesis

Before we deal with how to create a Custom Post Type in Genesis for your WordPress Website, we need to understand what a CPT is.

What is a Custom Post Type (CPT)

You are probably familiar with the general posts that are automatically set up with WordPress, e.g., post, pages, attachments, etc. A custom post type is a webpage which is created to fulfil a need for particular content.  It gives you the option of creating a new type of post that has different customised fields or to give new category structure, e.g., movie reviews, portfolio, products, etc.

Why would you want to use a Custom Post Type in Genesis?

Custom Post Types are great for separating out content within your website. For example, I wanted to make a CPT for tutorials so these more technical posts would not fill up my blog. The plugin Testimonial Rotator creates a CPT with styles and functions specific to testimonials.

How to add a Custom Post Type to Your WordPress Genesis Framework website

There are two options:

  1. Add code to your functions.php file
  2. Using  a plugin

Create a Custom Post Type in Genesis by adding code to your functions.php file:

I used Carrie Dils tutorial: How to Create an Archive Template for a Custom Post Type and added her code to my functions.php file.

However, I already have a portfolio CPT on this site: so bearing in mind that you presumably want something unique as well; I edited the code to show any changes that should be made.

https://gist.github.com/cdils/4f3616d8318abab50cf0

Below is how to register a custom post type called Tutorials, and comparing the two will ensure you do not miss any changes to your unique CPT.

//* Add a custom post type
add_action( 'init', 'cd_post_type2' );
function cd_post_type2() {
  // Tutorial custom post type
	register_post_type( 'tutorial',
		array(
			'labels' => array(
				'name' => __( 'Tutorials' ),
				'singular_name' => __( 'Tutorial' ),
			),
			'has_archive' => true,
			'public' => true,
			'show_ui' => true, 
			'show_in_menu' => true, 
			'rewrite' => array( 'slug' => 'tutorials' ),
			'supports' => array( 'title', 'editor', 'genesis-seo', 'thumbnail','genesis-cpt-archives-settings' ),
		)
	);
}

If you want to create more than one CPT, the function name needs to be changed each time, e.g., where it has cd_post_type, you can change that to cd_post_type2, etc.

A possible disadvantage of the functions.php method

Something to bear in mind when using the functions.php method: if you change your theme the CPT is going to be lost. The information will all be there in your database, but it will look like it has disappeared. It will not display on your website. To fix this, you could export and import a CPT:  how to export and import a CPT.

Another option is to use the Post Type Switcher Plugin, this includes bulk editing, where you can select all the posts in a type and convert them to a new type with one quick action. For example, I could convert all my tutorials to a standard post type.

I am not planning on changing my theme anytime soon, and I still have the option to export my tutorials to a new website, so I am happy with the functions.php option.

Create a Custom Post Type in Genesis using a plugin

The other option is to use a plugin e.g., https://jackiedelia.com/genesis-communities-cpt-plugin/

or https://wordpress.org/plugins/custom-post-type-ui/

 

 

Get In Touch!

027 608 2001

1/1 Korau Road, Greenlane, Auckland 1051

tarnya@buildyourwebsite.co.nz

Additional Resources

  • WordPress Website Care Plans
  • Web Design for Tradies
  • Websites for Psychologists and Counsellors
  • Web Design for Charities
  • Website Pricing
  • Website Design and Build Process
  • Website Design Case Studies
  • Articles
  • Blog
  • Technical Tutorials
  • Privacy Policy
  • Terms and Conditions for Website Services
  • Website Terms and Conditions
Copyright © 2022 Kitchen Table Web Design. All Rights Reserved.