I am using BB child theme and have a custom post type of ‘testimonial’.
I want to have extra text display in front of the post title on every testimonial.
I have copied single.php and content-single.php to the child theme folder and tried renaming them but I can’t seem to get a custom template to work for the custom post type - what changes need to be made?
Hey Chris! Thanks for reaching out with your question! Just to clarify, are you using a Custom Page Template? I believe to create a Custom Post Template, you’d need to use a plugin as WordPress’ doesn’t have that functionality baked in. I might be mistaken on that, though.
Many thanks for the reply. But I must have not explained things well, or I completely have it wrong.
I have created a custom post type called feedback. Normally in WordPress I believe this would use the single.php template unless I create a template named single-feedback.php.
So I would expect to copy the single.php file to the child theme folder and rename it to single-feedback.php and edit it according to my wishes.
But I can see the BB theme has content-single.php and single.php so I am unclear about how to get my custom post type to use a specific template.
The customising needs to be done in content-single.php but how should that file be renamed - content-single-feedback.php? And the file ‘single.php’ should presumably be renamed to ‘single-feedback.php’ but looking in that file I am not sure if I need to edit “get_template_part”
I hope that explains things a little more and that you may be able to help
After reading a bit closer, I was wrong. WordPress does support custom post types and custom page types “out of the box.” Sorry for the confusion there.
What you’ll probably want to do is copy/paste everything from content-single.php into your single-feedback.php file in place of the get_template_part line. So, in content-single.php it would look like this:
Hmm. So this issue is that you created the custom post type template and it’s not loading?
You could try re-saving your permalinks. I read that this can help. Also, double check that the file name is setup exactly has the codex recommends in this article: http://codex.wordpress.org/Post_Type_Templates
I don’t believe there is anything within our theme that would affect the ability to create custom post type templates, but from experience I know that it is crucial to make sure the file names are exactly as the Codex recommends.
Let me know if that doesn’t help and we can explore the issue further.
Just about to leave the workshop for the evening and saw this post - perhaps the following will help?
Copy both files and rename single.php to single-feedback.php and content-single.php to content-feedback.php (or whatever you would like) and make sure to change the call to content-single.php to match your new filename (content-feedback.php)
Or you can add a conditional statement to single.php to call a different content-x.php as needed.
Hope that makes sense, but if not I will be back in work tomorrow and will watch out for a reply!