Add Custom Post Type To Any Theme

This code enables you to create a Custom Post Type in any WordPress theme.

members custom post type

Simply copy the PHP code from the view raw link and paste it at the end of your child themes functions.php file using a text editor like Notepad++.

Once you’ve added the code, go to Settings > Permalinks and re-save your Permalinks which flushes the cache for your re-write rules.

The code also creates:

  • An archive page with pagination to list your single custom post type pages
  • Support for adding custom taxonomy types (which are like categories for custom post types)

If you don’t want to add support for creating custom taxonomy types, you can replace this line of code:

'taxonomies'   => array( 'member-type' ),

With this code which enables you to create categories for your CPT:

'taxonomies'   => array( 'category' ),

Change Name of Custom Post Type (CPT)

You can easily change the name of your custom post type simply by changing all instances of member and members to whatever you like and then re-save your permalinks.

Add Pagination to CPT Archive Pages

This PHP code, once added to your functions.php file, enables you to determine how many CPT items display on your archive page. If you have added 12 items and this code includes 6, then page navigation will be added to the end of the archive to link to page 2 which contains the other 6 CPT items.

Simply replace Your CPT Name in the code with the name of your custom post type and re-save your Permalink settings.

Change Layout

You can change the layout of your custom post type archive page or single post template for custom post types using code directly in a template file for your CPT or using a custom function to conditionally change the layout.

Unlike standard posts and pages, a custom post type Edit screen does not include layout settings.

Themes Which Include Custom Post Type Support

You can also easily add a CPT with portfolio style archive page to any StudioPress theme.

Here’s an example of what the Lifestyle Pro theme looks like once you’ve added a Custom Post Type with Portfolio style page.

Other themes from StudioPress like the Executive Pro & Minimum Pro themes already include a custom post type with taxonomy type support and Portfolio page template.

More Tips When Using Custom Post Types

Get 50% OFF the fastest WordPress hosting for the first 3 Months.

Expiration Date: Expires 1/1/15 WP Engine hosting Rules: Only valid for new customers with Personal, Professional, and Business Plans. Not intended for internal use by wpengine affiliates.

Leave a Reply

Your feedback is always appreciated.

Your feedback is always welcome & appreciated however you must be logged in to get solutions for questions asked in the comments.