Vidya L
Vidya L

Reputation: 2314

How to create template for post in wordpress

I know how to create a custom template for a specific wordpress page. However, I would like to create a template for a specific custom post type. Is that possible and if it is possible, how can I do that?

Upvotes: 3

Views: 130

Answers (2)

Abhimanue Tamang
Abhimanue Tamang

Reputation: 580

If you have created a custom post type

If you have created a custom post type then you need to create a template who's name will be smiler to the custom post type for example if you have created a custom post type "product" then you will create a template with name product.php in your theme directory and to display a particulate post of your custom post type you will create another template with name single-product.phpthis template will be used to display your custom post and remember whatever custom post you create same name will be used to name your custom post type template and do not forget to add single in the beginning.

Template for a particulate post or a post of particulate category

And to display particular post in different template and to use different template to display post of particular category you can follow this link.

Upvotes: 0

RRikesh
RRikesh

Reputation: 14381

To add a custom template for custom post types you can use single-{posttype}.php template. You can look at the template hierarchy diagram for more details.

For example if your post type is called books, your filename for the template should be single-books.php

Upvotes: 4

Related Questions