WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Mar 21 2011

How to Create a WordPress Custom Post Type Template in Genesis

Custom post types can be rather confusing, daunting, intimidating, and frankly difficult. However, with Genesis, custom post types are easy as registering your post type, creating a template, and adding a page that uses the template. While I will assume that you know how to register your custom post type, if you don't download Brad William's/WebDevStudios' Custom Post Type UI Plugin.

To create your page template, you can simply download it here ([download id="5"]), or follow these instructions. In your favorite text editor, create a new document. Then add the following code:
[php]<?php
/*
*Template Name: Custom Post Type Template
*/

remove_action('genesis_loop', 'genesis_do_loop');
add_action('genesis_loop', 'custom_do_loop');
function custom_do_loop() {
global $paged;
$args = array('post_type' => 'my_post_type');
//$args = array('post_type' => 'books');

genesis_custom_loop( $args );
}
genesis();
?>[/php]
Template Name: Custom Post Type Template identifies it as a page template, so when you click Pages > Add New, your new template will appear in the right hand side for Page Templates as whatever you named it. To customize this template, change my_post_type to whatever you named your post type, which should be all lower case with no spaces. The default is 'post', which does not pick up your custom post type.

Written by Travis Smith · Categorized: Genesis, Tutorials

StudioPress Premium WordPress Themes     WP Engine Managed WordPress Hosting

What can I do for you!?

Custom Development

We develop plugins by determining both business/functional and technical requirements, following WordPress development best practices, and using agile methodology to ensure you get the best solution.

Consulting

Have questions? Need a reliable developer to consult? Please contact us today!

Customized Theme

We can customize your theme or child theme, or create a child theme for you based on your needs while enhancing the performance of every individual attribute.

Customized Plugin

We can customize your plugins, extend plugins (e.g., Gravity Forms, Jetpack, Soliloquy) based on your needs ensuring security, performance, and positive business impact.

Contact Us

About Travis Smith

As a WordPress enthusiast, developer, and speaker, Travis writes about what he learns in WordPress trying to help other WordPress travelers, beginners and enthusiasts with tutorials, explanations, & demonstrations.

Comments

  1. Gré says

    April 5, 2011 at 9:33 pm

    Hi Travis
    Thanks for sharing.
    And i you want to add some custom taxonomy on these post type you can add this:

    // Add meta after post
    remove_action(‘genesis_after_post_content’, ‘genesis_post_meta’);
    add_action(‘genesis_after_post_content’,’gncom_ajouter_custom_tax_atelier_lisaa_archives’,30);
    function gncom_ajouter_custom_tax_atelier_lisaa_archives() {
    $gncom_taxo_term = get_the_term_list( $post->ID , ‘les_ateliers’, ‘Les Ateliers: ‘,’, ‘,”);
    echo ” . $gncom_taxo_term . ”;
    }

    Reply
    • Travis Smith says

      April 6, 2011 at 1:15 pm

      Thanks for sharing! I believe you need to declare $post as global.

      Reply
  2. Tracey Rissik says

    April 28, 2011 at 1:57 pm

    Hi Travis,

    fantastic post, thanks – it made the job so simple!

    By the way, I also read about the “Genesis Simple Hooks” plugin, so that you can remove the post-type stuff like date, author etc. from displaying – not figured out how to make it post-TYPE specific (that may not be possible) … but this may be of use to your readers (or you)

    Kind regards,
    Tracey

    Reply
    • wpsmith says

      April 28, 2011 at 3:23 pm

      Hello Tracey,

      Yes, Genesis has several plugins that are specific to its use/purposes. You can see my post about this as well: “Simple” Plugins Developed Specifically for Genesis by the StudioPress/Genesis Community. While I don’t use the Simple Hooks Plugin, it is a VERY good plugin and VERY useful for those starting out. I know the Thesis Hooks Plugin was essential for me in understanding hooks when I first started out.

      Reply
  3. Mel says

    July 22, 2011 at 1:54 pm

    Great post. I will be trying this one in a little while. I’m new to wordpress/php and jumped right into Genesis.

    Reply
    • wpsmith says

      July 22, 2011 at 3:13 pm

      Genesis is great! You’ll love it!

      Reply
  4. Sagive says

    December 27, 2011 at 12:29 pm

    Sorry mate, but this is not a custom post type but just the page that hold (like a category) the post types but what about a custom single.. ?

    Reply
    • Travis Smith says

      December 27, 2011 at 1:01 pm

      Correct. This is actually, technically a page template and not a custom post type template. This is actually the almost equivalent to archive-{post_type}.php. This code is best used for the archives display of a custom post type since Genesis handles single custom post types quite well (minus the ability to input extra custom fields), but even then, with the hooks, that’s fairly easy to accomplish. However, I have a series “coming soon” that will walk through everything for Genesis.

      Reply
  5. Van Wilson says

    November 8, 2012 at 8:23 am

    I am new to Genesis, and this tutorial helped me greatly.
    I noticed that the links to download your template code, such as the one on this page (Custom Post Type Page Template (474)), are broken.

    Reply
    • Travis Smith says

      November 12, 2012 at 5:32 pm

      Thanks! Fixed.

      Reply
  6. username says

    July 30, 2014 at 10:07 am

    There is nothing about custom post type but custom page type. What a difference!

    Reply

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in