Community Forums › Forums › Archived Forums › Design Tips and Tricks › Creating a New Template for a Custom Post Type
Tagged: CPT, Custom Post Type, parallax, template
- This topic has 14 replies, 5 voices, and was last updated 10 years, 6 months ago by
Andrea Rennick.
-
AuthorPosts
-
August 9, 2014 at 12:32 pm #117944
omerkhan
MemberI'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.
August 9, 2014 at 2:05 pm #117982JanHoek
ParticipantMaybe 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.
August 9, 2014 at 5:23 pm #118000omerkhan
MemberHi 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
August 9, 2014 at 8:11 pm #118009Summer
MemberGenesis 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
WordPress / Genesis Site Design & Troubleshooting: A Touch of Summer | @SummerWebDesign
Slice of SciFi | Writers, After DarkAugust 9, 2014 at 8:23 pm #118011omerkhan
MemberThanks 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?
August 9, 2014 at 8:50 pm #118013omerkhan
MemberAlso, 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
August 9, 2014 at 9:50 pm #118018Summer
MemberDid 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).
WordPress / Genesis Site Design & Troubleshooting: A Touch of Summer | @SummerWebDesign
Slice of SciFi | Writers, After DarkAugust 9, 2014 at 11:00 pm #118023Brad Dalton
ParticipantTry 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.
August 10, 2014 at 8:39 pm #118129omerkhan
MemberVery nice Brad! That post threw me for a second when you mentioned some 'other guy' named Omer. 🙂
August 10, 2014 at 8:40 pm #118131omerkhan
MemberI 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!
August 10, 2014 at 8:41 pm #118132omerkhan
MemberBut 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!
August 10, 2014 at 9:12 pm #118133Brad Dalton
ParticipantOmer
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.
August 11, 2014 at 10:12 am #118130omerkhan
MemberI 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!
August 11, 2014 at 10:12 am #118209Andrea Rennick
Memberplease 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.
August 13, 2014 at 2:09 pm #118117omerkhan
MemberVery 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
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.