Creating a New Template for a Custom Post Type

Community Forums Forums Design Tips and Tricks Creating a New Template for a Custom Post Type

This topic is: not resolved

This topic contains 14 replies, has 5 voices, and was last updated by  Andrea Rennick 2 months, 1 week ago.

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #117944

    omerkhan
    Participant
    Post count: 13

    I’m using the Parallax Pro child theme and have created a new custom post type called Podcasts.

    I’d like to be able to create a page at http://www.mydomain.com/podcast that shows me a summary of all podcast posts. This would be exactly how http://www.mydomain.com/blog shows me a summary of my blog posts.

    I’ve created a new template in my child theme folder called page_podcast.php, based on the code from the page_blog.php file in the Genesis folder (see below).

    <?php
    /**
    * Genesis Framework.
    *
    *
    * @package Genesis\Templates
    * @author StudioPress
    * @license GPL-2.0+
    * @link http://my.studiopress.com/themes/genesis/
    */

    //* Template Name: Podcast

    //* The blog page loop logic is located in lib/structure/loops.php
    genesis();

    In the dashboard I can see a new “Podcast” template from the drop down menu (along with Default, Archive, Blog, Landing etc.).

    But I’m not sure what I need to do next to get the Podcast custom posts actually showing up when I use this template.

    #117982

    JanHoek
    Member
    Post count: 214

    Maybe this is helpfull http://thewpchick.com/genesis-for-podcasting-yep-perfect-for-podcasters-too/


    Hi, my name is Jan Hoek. Sure, they all say I have a big head, but I like to think it’s way too small for all my ideas.

    #118000

    omerkhan
    Participant
    Post count: 13

    Hi Jan

    Thanks for your sharing. I’m trying to do exactly what she’s done on her site:

    A page for blog post summaries: http://thewpchick.com/blog/
    A page for podcast post (custom post type) summaries: http://thewpchick.com/podcast/

    Unfortunately, she doesn’t explain how she did that in that particular article.

    –Omer

    #118009

    Summer
    Participant
    Post count: 1105

    Genesis will automatically generate an archive of your custom posts for you. So if you have active posts in Podcast, and your post slug is podcast, then http://my.domain.com/podcast/ would automatically be your custom post type archive.

    Try deleting the page you called Podcast, and see what happens.

    Now if your CPT is Podcasts and your slug is podcasts, then you need to use http://my.domain.com/podcasts/ instead


    #118011

    omerkhan
    Participant
    Post count: 13

    Thanks Summer.

    The custom posts I create, have the following URL structure http://my.domain.com/podcast/each-custom-post-name

    I deleted the Podcast page/template and tried accessing http://my.domain.com/podcast (and http://my.domain.com/podcasts) but both return a 404 error now.

    Any other ideas?

    #118013

    omerkhan
    Participant
    Post count: 13

    Also, one other insight that might help troubleshooting this….

    In order for http://my.domain.com/blog to show a summary of blog posts, I have to have to create a page at http://my.domain.com/blog and set that as ‘blog’ template type. If I delete that page, then I get a 404 error.

    That’s why I assumed that I needed to create a ‘podcast’ template type and then create a page at http://my.domain.com/podcast and set that as ‘podcast’ template type. But that was just a total guess.

    Also, I didn’t mess around with any of the blog templates — as far as I know, that’s how it’s been working since I did a clean install of WordPress with Genesis/Parallax Pro.

    –Omer

    #118018

    Summer
    Participant
    Post count: 1105

    Did you reset your Permalinks after creating the CPT? Just go to the Settings > Permalinks menu, and that should should “reset” things for you.

    And no, you don’t always have to use the “blog” page to have a list of your blog posts unless you want the URL to be just the word “/blog/” instead of “/category/category-name/” (which is the default listing for your regular posts).


    #118023

    braddalton
    Participant
    Post count: 10217

    Try this http://wpsites.net/web-design/create-a-new-template-for-a-custom-post-type-archive/

    If the code you use to create the CPT includes a setting to display the archive, it should be set to ‘true’ and WordPress will display a archive page without any need to create and add one to your child theme.


    #118129

    omerkhan
    Participant
    Post count: 13

    Very nice Brad! That post threw me for a second when you mentioned some ‘other guy’ named Omer. :-)

    #118131

    omerkhan
    Participant
    Post count: 13

    I setup the custom post type using the Custom Post Type UI plugin. The problem was that under the ‘advanced settings’, I hadn’t set “archive = yes” and defined the slug as podcast. Then I created a new page called page_podcast.php to create a podcast template using these instructions http://designsbynickthegeek.com/tutorials/creating-page-templates-in-genesis.

    But after reading your post (and the one on creating custom post types), I thought it would be much better to follow your advice on creating custom post types in functions.php. That way I could uninstall the Custom Post Type UI plugin.

    Then I created the archive page, updated permalinks, added a link to http://my.domain.com/podcast and it worked!

    #118132

    omerkhan
    Participant
    Post count: 13

    But there were two small issues that I still needed to address:

    1) The podcast archive page looked a little different to the blog page (because that links to a page using the ‘blog’ template type that came with Parallax Pro) e.g. the podcast archive page would show the date or author under the headline.

    2) I want at some point to be able to add some static content on the top of the podcast archive page at some point, so I am assuming creating a podcast page using a podcast template type would be the best way to do that. Not sure.

    Anyway, so the one tweak that I made was to remove the archive-podcast.php file and instead put back the page_podcast.php (following these instructions) and then I created a page called podcast at http://my.domain.com/podcast and set it up to use the podcast template type that I just created.

    Now both my blog section and podcast section look identical in terms of layout.

    Brad — I did have two questions for you:

    1. What are the pros & cons of using an archive page vs. a page with a ‘podcast’ template? Does it make a big difference?

    2. On your page for creating custom post types, you have the following code:

    ‘name’ => __( ‘Members’, ‘wpsites’ ),
    ‘singular_name’ => __( ‘Member’, ‘wpsites’ ),

    I understand that I should replace Members/Member with Podcasts/Podcast, but what is the ‘wpsites’ value used for?

    And thank you for your help!

    #118133

    braddalton
    Participant
    Post count: 10217

    Omer

    1) The podcast archive page looked a little different to the blog page (because that links to a page using the ‘blog’ template type that came with Parallax Pro) e.g. the podcast archive page would show the date or author under the headline.

    Solution: Remove the PHP code that removes the entry meta in the entry header

    2) I want at some point to be able to add some static content on the top of the podcast archive page at some point, so I am assuming creating a podcast page using a podcast template type would be the best way to do that. Not sure.

    Solution: You can hook in another widget from your functions file or hard code one into the template. Or you can add support for the standard fields. Please start another question for this.

    1. Already answered this in my post. The custom archive CPT template can be customized. The standard archive is standard.

    2. Yes, replace Member with the name of your CPT as indicated in that post and re-save Permalinks.

    wpsites is the $text_domain which i use when testing locally. You can change it to your own.


    #118130

    omerkhan
    Participant
    Post count: 13

    I setup the custom post type using the Custom Post Type UI plugin. The problem was that under the ‘advanced settings’, I hadn’t set “archive = yes” and defined the slug as podcast. Then I created a new page called page_podcast.php to create a podcast template using these instructions http://designsbynickthegeek.com/tutorials/creating-page-templates-in-genesis.

    But after reading your post (and the one on creating custom post types), I thought it would be much better to follow your advice on creating custom post types in functions.php. That way I could uninstall the Custom Post Type UI plugin.

    Then I created the archive page, updated permalinks, added a link to http://my.domain.com/podcast and it worked!

    But there were two small issues that I still needed to address:

    1) The podcast archive page looked a little different to the blog page (because that links to a page using the ‘blog’ template type that came with Parallax Pro) e.g. the podcast archive page would show the date or author under the headline.

    2) I want at some point to be able to add some static content on the top of the podcast archive page at some point, so I am assuming creating a podcast page using a podcast template type would be the best way to do that. Not sure.

    Anyway, so the one tweak that I made was to remove the archive-podcast.php file and instead put back the page_podcast.php (following these instructions) and then I created a page called podcast at http://my.domain.com/podcast and set it up to use the podcast template type that I just created.

    Now both my blog section and podcast section look identical in terms of layout.

    Thanks for your help!

    #118209

    Andrea Rennick
    Keymaster
    Post count: 1302

    please note that including 3 links or more in your post will always place your post in moderation.


    **forum signature**
    If you need technical support for your theme please file a ticket.

    The forums are community based. Staff only monitors the forum for issues relating to the forum itself and to redirect users to where they need to go.

    Twitterholic

    #118117

    omerkhan
    Participant
    Post count: 13

    Very nice Brad! That post threw me for a second when you mentioned some ‘other guy’ named Omer. :-)

    I setup the custom post type using the Custom Post Type UI plugin. The problem was that under the ‘advanced settings’, I hadn’t set “archive = yes” and defined the slug as podcast. Then I created a new page called page_podcast.php to create a podcast template using these instructions http://designsbynickthegeek.com/tutorials/creating-page-templates-in-genesis.

    But after reading your post (and the one on creating custom post types), I thought it would be much better to follow your advice on creating custom post types in functions.php. That way I could uninstall the Custom Post Type UI plugin.

    Then I created the archive page, updated permalinks, added a link to http://my.domain.com/podcast and it worked!

    But there were two small issues that I still needed to address:

    1) The podcast archive page looked a little different to the blog page (because that links to a page using the ‘blog’ template type that came with Parallax Pro) e.g. the podcast archive page would show the date or author under the headline.

    2) I want at some point to be able to add some static content on the top of the podcast archive page at some point, so I am assuming creating a podcast page using a podcast template type would be the best way to do that. Not sure.

    Anyway, so the one tweak that I made was to remove the archive-podcast.php file and instead put back the page_podcast.php (following these instructions) and then I created a page called podcast at http://my.domain.com/podcast and set it up to use the podcast template type that I just created.

    Now both my blog section and podcast section look identical in terms of layout.

    Brad — I did have two questions for you:

    1. What are the pros & cons of using an archive page vs. a page with a ‘podcast’ template? Does it make a big difference?

    2. On your page for creating custom post types, you have the following code:

    ‘name’ => __( ‘Members’, ‘wpsites’ ),
    ‘singular_name’ => __( ‘Member’, ‘wpsites’ ),

    I understand that I should replace Members/Member with Podcasts/Podcast, but what is the ‘wpsites’ value used for?

    And thank you for your help!

    –Omer

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in to reply to this topic.