Skip Navigation

[Resolved] Custom php template part is not being applied to custom post

This support ticket is created 3 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 3 replies, has 2 voices.

Last updated by mashaB 3 years, 10 months ago.

Assisted by: Shane.

Author
Posts
#2109469
vob-news_post-slug.png

Tell us what you are trying to do?
Use custom php template part for a Custom post type

Is there any documentation that you are following?
https://toolset.com/documentation/customizing-sites-using-php/creating-templates-single-custom-posts/
https://developer.wordpress.org/themes/basics/template-hierarchy/

Hi!

I was not able to use Toolset Custom Content Template feature to achieve customization required for my site. So, I have decided to create custom php template. My theme (Purea Magazine pro) is using template parts , based on my research I need to create content-single.php for my custom post.

My custom post slug is "vob-news" and it is created via Toolset Types.
Then, in my theme templates folder I added content-single-vob-news.php and modified code as required.

But this custom template is not being respected when rendering posts of that type. Is there anything I am missing? Reading questions about custom posts not managed by Toolset it seems that I am doing everything correctly. Is there any specifics how Toolset registers and manages custom post types?

#2109479
vob-news_content-single.png
vob-news_post-slug.png

Adding screenshots from my site.

#2109529

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Masha,

Thank you for getting in touch.

It would appear that your theme is using template parts. It would be best to contact your theme's author for how to format the custom post type name into the template part filename.

However you can try content-{cpt-slug}.php

Additionally if you want to use the Toolset Content templates and the templates are not showing up then you can use the Content template debugging function.

Generally when a theme isn't displaying the content template on the frontend it means that the theme is not using the standard wordpress functions to display the post. In this case the content template debug is used to find what the function is that is being used.

To find this function go to Toolset -> Settings -> Frontend and scroll to Theme support for Content Templates and enable the "Theme Support Debug" option.

From there assign your content template to any page and preview that page on the frontend. You should now be seeing the function that is being used. Just copy the function to the content template debug and your template should now start to show.

Thanks,
Shane

#2109683

Shane, as I said I cannot utilize ToolSet's content template as it is pretty limited to the content area. The theme we use renders bunch of metadata outside the_content(), for example tags. If I use tags inside ToolSet's content template then I need to suppress it in the theme somehow. So, having custom php templates is the only option as I can see.

However, I was able to find where the theme uses get_template_part() and found out that they hardcode file name without looping through templates based on post type. I understand it now that this is outside Toolset's responsibilities, maybe the above references document can be improved.

Thanks again for the help!