[Resolved] Content Template shortcode inside page not working (no View used)
This thread is resolved. Here is a description of the problem and solution.
Problem:
The issue here is that the users shortcodes were not rendering any data.
Solution:
In this user's case they were calling the shortcodes for data that was not present on the post itself.
Once the user added the shortcodes to the appropriate template that is when the data started to show up.
This support ticket is created 5 years, 5 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.
Do you intend to use our Layouts plugin as ? As I would suggest that rather than calling the content template directly from the post body you assign the post itself to a template.
No, I do not plan to use the Layouts plugin, and have no other use for it at this point. This site has been designed over 5 years ago and works fine, except I had a problem with this page recently. Beda (Toolset Support) figured out what the problem was, related to conditionals. But, I was using a View + Content Template for this, but since there is never more than one Treasurer post, Beda suggested I remove the View and put the Content Template shortcode directly in the Page.
I have looked up in Toolset documentation regarding this, and it looks simple. But, I don't know why it doesn't work on my page.
I was expecting to send this issue to Beda, but instead, Luo's name came up so, I just selected "Anyone from Toolset..."
Shane -
Ha! Yes, that makes sense!
It worked before because I was going through the View called Membership Renewal. And I see now that at the bottom of the Content Template page, I do not have a post type selected. But I don't think that will make a difference. The problem at the moment is not that there is no data being displayed; it's that the shortcode is not being parsed as it should be. Like it's not being recognized as a shortcode.
I have a Duplicator package already to go (for Beda 2 days ago) on my Dropbox. Please enable a Private Reply so I can post the link to it here. Or else, you can run Duplicator yourself; however, this staging domain is not authorized for Duplicator Pro.
I restructured the CT by splitting the second conditional block into two conditionals, as suggested by Beda (Toolset Support.) At least that allows for the shortcodes to be parsed. However, now the data does not display.
Note that the initial issue here was that the data does not display even when using a View to call the CT. Beda found a known issue with shortcode memory limits in WordPress - not something Toolset can fix. So, splitting that CT block into two conditionals is the only safe workaround, even though it costs several more database query hits.
So, if you still want to have a look at this, I can send you a link to a Duplicator package - or you can create one yourself from the site Admin panel.
Perhaps using Views Debug will be of some help now. I will take a look.
However the issue with the shortcodes now not displaying the values is that they are looking for the values from the current post.
Remember you are calling the current post body with this content template, essentially passing the post ID into the content template. Looking at the posts none of the fields that the shortcodes should display are on this membership renewal page and this is what the fields need for the value to be displayed.
Perhaps you can let me know which post type these fields are attached to.
Oops!
Shane - I forgot to mention I noticed that I had not set the post type at the bottom of the CT. The post type is "Treasurer Contact Infos". I tried enabling those checkboxes but it still didn't display the data. So, I'm at a loss for how to connect the correct post type. Can I do that in the shortcode?
This organization changes their treasurer every 1 or 2 years, so I created that CPT to allow their admin to easily make the change throughout the site (3 pages). There is never more than a single post in the database for this post type, because I have instructed them to overwrite the same post every time they change the information to a new treasurer.
Yes, exactly!
I just did a quick try of that and it works.
The problem is, in the future if my client ever accidentally deletes that one post for the Treasurer Infos CPT and creates a new post for the next treasurer (I warned them not to do that but...) it will break this page.
Any ideas how to avoid that?
What about adding a filter for delete_post and not allow this post_id to be deleted. Ever. ???
Jeff
------------