Skip Navigation

[Resolved] How and where can a Content Template be displayed?

This thread is resolved. Here is a description of the problem and solution.

Problem:
Can a Content Template only be assigned to posts and replace their Post Body or can we also use this elsehow?

Solution:
Content Templates, if assigned to a post, will replace the Content of that post.
If you need to display a Content Template independently from the Post Body you'd need to use PHP or other methods to output it in the Themes sections you want which are not the post body.

[wpv-post-body view_template="slug-of-your-content-template"]

is a shortcode, and classically in WordPress you will insert this in a Text Editor of a Post, or else, you can hence display this anywhere you have Text Editors and output that content somehow in the Front End.

You can also insert a Content Template ShortCode in PHP Templates using do_shortcode(), but better would be to use Views API to display that Content Template in PHP:
https://toolset.com/documentation/programmer-reference/views-api/#render_view_template

This support ticket is created 4 years, 7 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 4 replies, has 2 voices.

Last updated by martinP-13 4 years, 6 months ago.

Assisted by: Beda.

Author
Posts
#1509771

this content template here hidden link

the single-event.php displays the content after the title like here hidden link

i need the content template to display where the word ++++++++++++here++++++++++++++ is displayed on the page instead ?

my single event php is located here hidden link

is it possible?

<removed>

#1510137

Well, Content Templates are intended to replace what WordPress themes usually output by using the_content() function.
That is usually just below the Post Title, since it is the Post Body, so to speak.
https://developer.wordpress.org/reference/functions/the_content/

Hence, when you assign a Content Template to a single or many posts, it will replace exactly that part of the Theme Code.

If you instead want to display a Content Template "anywhere" on a post (so, not replacing the_content, or post body, but anywhere you insert it), you can do this by using a ShortCode.
You will find it in the "Fields and Views" GUI where you can search for "post body".
The ShortCode looks like this:

[wpv-post-body view_template="slug-of-your-content-template"]

Also, you can call a Content Template with PHP:
https://toolset.com/documentation/programmer-reference/views-api/#render_view_template

I could not see the front end of your page as it says it is for subscribers only, even I was logged in.
But above should describe well how you'd add that template to the desired location, wether with a shortcode or PHP

Please let me know if anything remains unclear.
PS:
I removed your access data because these posts are public.

#1519817

thanks beda ,[wpv-post-body view_template="slug-of-your-content-template"] does this go in the content template or my php file for the post type? i tried the content template but it just added a warning for infinate loop. thanks

#1520197

[wpv-post-body view_template="slug-of-your-content-template"] is a shortcode, and classically in WordPress you will insert this in a Text Editor of a Post, or else.

You can of course always insert this in PHP as well using do_shortcode(), or you can use Views API to display that Content Template in PHP:
https://toolset.com/documentation/programmer-reference/views-api/#render_view_template

The infinite loop you get is because you insert the [wpv-post-body view_template="slug-of-your-content-template"] shortcode inside each other.
That does not work

As said, Content Templates, if assigned to a post, will replace the Content of that post.
If you need to display a Content Template independently from the Post Body you'd need to use PHP or other methods to output it in the Themes sections you want which are not the post body.

However this is not something Toolset Support can help with, as it is a customization of the Theme.
You'd need to use https://toolset.com/documentation/programmer-reference/views-api/#render_view_template in the case you want to add the changes to a Child Theme, for example.
That would allow you to call any Content Template, anywhere you want, in the Theme's template Files (or well, even sidebars, if the Theme has any)

#1524149

My issue is resolved now. Thank you!

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.