I’m making my first custom theme using custom post types and I’ve encountered one problem.
I’d like to make some templates like you can make for Pages (i.e. page-fullwidth.php page-noslider.php etc.)
I know if you want to make template for custom post type you just make for example single-cookingrecipes.php but I’d like to make single-cookingrecipes-fullwidth.php and some more.
I have created 2 such files and added
<?php
/*
Template Name: Art
*/
?>
and still no luck 🙁
It sounds like you are talking about this page display template:
And you want
single-{cpt-slug}-{slug}.php
.If so, I believe you can approximate that page template handling with the following:
Custom post type can have template options like Pages, but its little complex, but i will try to explain it:
1) you need to register a new meta box with a drop down (custom meta field) of all the templates:
2) Save/Delete the content of the new meta field when the post saved.
3) The key part for loading the custom template you created is here
any issues , let me know
Suppose you make a new page call art.php
Next step you should do is to Go to your admin dashboard. Then follow the simple steps.
That’s it.