June 6, 2013 at 6:47 pm #44452
I've created a custom post type and I'd like to have the archive page display like the portfolio page rather than like the blog page.
How do I do this?
Do I just copy and rename the archive-portfolio.php file? What do I need to put in the functions.php to link it up with the custom post type?
Oh and is it simple enough to display an excerpt under the image?
Thanks so much,
June 6, 2013 at 8:31 pm #44466
You are correct about the copy/rename of archive-yourcustomposttype.php file. WordPress will automatically know to look for that file. If the file is not there, WordPress will use the archive.php file. If that is not there, it will look for index.php.
Hope this clears it up.
June 7, 2013 at 2:16 am #44479
Thanks for the quick response rfmeier.
I've duplicated the file and name it archive-(custom post slug).php however it's not using it.
I'm using the Custom Post Type UI by WebDevStudios for the custom post type, do I need to change anything in that file? I can't see anything that looks like needs changing ...
I've tried to find an answer on the plugin site too with no luckJune 7, 2013 at 5:15 am #44491June 7, 2013 at 4:28 pm #44654
should it perhaps only be one word?
EliseJune 7, 2013 at 5:44 pm #44660
Ok so I did an experiment and changed the slug for the custom post type to 'hire' and uploaded a copy of the portfolio file and named it 'archive-hire.php'
When I type in soulstories.net.au/hire it's an error 404
When I type in the old slug soulstories.net.au/wedding-event-hire the page works (weird?) and is in the portfolio format (except it's 1 column when it should be 3). When I type on the posts from this page it produced a 404 as it's using the new slug e.g. http://soulstories.net.au/hire/vintage-books
When I change the url to use the old slug it works http://soulstories.net.au/wedding-event-hire/vintage-books
I'm officially totally confused ... I've changed the slug to 1 word which has now made the porfolio archive page work however, it works only using the old slug ... the archive page is linking the posts using the new slug which doesn't work as the old slug works.
I now have both archive files uploaded (archive-hire.php and archive-wedding-event-hire.php) ... I tried deleting archive-wedding-event-hire.php to see if that would make the archive-hire.php work but it didn't.
Scratching my head.
EliseJune 7, 2013 at 5:51 pm #44663
That rings a bell fror me. Although since I am unsure how you are creating your custom post types. Plugin? Custom Code? Either way, when you create a custom post type for the first time in WordPress you need to flush your permalinks so the rewrite API has knowledge of the post type slug.
This can be done with code or you can go to your permalink settings and re-save them.
Try this with your new post type slug and let me know how it works out. I am not even sure this is the issue.
June 7, 2013 at 6:45 pm #44670
Oh of course! Ok I saved the permalinks again and now all is well!
Thank you so much! I will now add re-saving the permalinks as one of my checks
You are a legend!June 7, 2013 at 6:47 pm #44671June 7, 2013 at 6:52 pm #44672
Oh sorry I forgot to answer that. I'm using Custom Post Type UI by WebDevStudios (free) and I'm also using Advanced Custom Fields plugin but so far I can't work out how to actually display the fields ...
I'm quite excited to be getting acquainted with these custom post typesJune 7, 2013 at 7:02 pm #44673
You must be logged in to reply to this topic.