Site logo

Archived topic

Custom Post Template

5 replies · Started by Robbert on April 7, 2019

Viewing posts 1–6 of 6

Hi, this is probably a question that's been asked before, but from the support topics I read I still didn't understand it fully.

I'm trying to create a custom post layout so I can add some custom fields that will be the same on all those posts.

I thought I could simply copy single.php and put in the child theme folder as single-posttemplate.php and then I could select it in the post editor under Page Attributes. However, it doesn't show up. Or does this only apply to pages?

Some clarification would be appreciated. Thanks!

Hi Tom, I did add that indeed, and I do see the option to select the template when I make a new page. However, I think I misunderstood something, so please correct me if I'm wrong:

If I want to make a template for posts, I need to make a new custom post type first, and then single-customposttypename.php will be used for that? Meaning you can only have one template per custom post type, not multiple templates you can select in a dropdown menu like you can with pages.

Am I understanding it correctly?

Best, Rob

If it's just a template used for posts, you don't need to create a custom post type.

You'd just need to do something like this in the file header:

/*
 * Template Name: Featured Article
 * Template Post Type: post, page, product
 */

Thanks, Tom, it works. Don't know what I did wrong earlier.

Glad I could help! :)

This archived topic is closed to new replies.