Skip Navigation

[Resolved] How to show body of the post inside custom template

This support ticket is created 3 years 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 3 replies, has 2 voices.

Last updated by Waqar 3 years ago.

Assisted by: Waqar.

Author
Posts
#2235575

Tell us what you are trying to do?

I have a page where I show post depend on search param. I use custom template for it: [wpv-post-body view_template="blogpostmanagetemplate" item="[wpv-search-term param='postid']"]

Inside it I insert standard field wpf-body to show post text: [wpv-post-body view_template="None"].

But then I receive an error that I could not request post from the post (as it looks like recurrent request)

So, is there any way to show post body content within page depending on search param like "?postid=1"?

#2235865

Hi,

Thank you for contacting us and I'd be happy to assist.

I tested the same setup on my test website and it worked without any errors.

You can show the content/body from the post available in the URL parameter, using the same 'item' attribute and it should work too:


[wpv-post-body view_template="None" item="[wpv-search-term param='postid']"]

If you're still seeing the error, please share a screenshot, so that it is more clear.

regards,
Waqar

#2235903
postbodyerror.jpg

Hi!

I use this:

[wpv-post-body view_template="blogpostmanagetemplate" item="[wpv-search-term param='postid']"]

and inside it I use this:

[wpv-post-body view_template="None" item="[wpv-search-term param='postid']"]

And then I have an error:

"Content not displayed because it produces an infinite loop.
The wpv-post-body shortcode was called more than once with the same attributes over the same context, triggering an infinite loop."

#2238021

Thanks for writing back and for sharing the screenshot.

During further testing, I was able to see this warning message, only when no "postid" is provided in the URL parameter.

This makes sense, because when we provide another post/page ID in the "item" attribute of "wpv-post-body" shortcode, it gets the content/body from that post/page. But, if the "item" attribute is empty, then the same page's content/body is shown. And as the page's body contains the same shortcode, it results in looping over the same content, again and again.

To overcome, this you can wrap your parent/main level "wpv-post-body" shortcode in a conditional statement so that it is only shown when some "postid" is provided in the URL:
( ref: https://toolset.com/documentation/legacy-features/views-plugin/using-shortcodes-in-conditions/ )


[wpv-conditional if="( '[wpv-search-term param='postid']' gt '0' )"]
[wpv-post-body view_template="blogpostmanagetemplate" item="[wpv-search-term param='postid']"]
[/wpv-conditional]