Skip Navigation

[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.

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)

Tagged: 

This topic contains 18 replies, has 2 voices.

Last updated by Shane 5 years, 5 months ago.

Assisted by: Shane.

Author
Posts
#1271889
Screen Shot 2019-06-18 at 10.50.35 AM.png

I am trying to:
Display data using Types from a CT in a page, and not using a View.

Link to a page where the issue can be seen:

I expected to see:
The data from the Types shortcode.

Instead, I got:
The shortcode displayed as text.

Maybe I am doing it incorrectly? Do I need to change something in the CT?

This is the whole code in my page:

<div class="pageTitleBar">
  <div class="pageTitleBar_left">Membership Renewal</div>
  <div class="pageTitleBar_right">[members only]</div>
</div><!-- pageTitleBar -->
<div>
  [wpv-post-body view_template="Membership Renewal"]
</div>
#1271943

Shane
Supporter

Languages: English (English )

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

Hi Jeff,

Thank you for contacting our support forum.

Would you mind allowing me to have admin access to the site to check on this for you ?

The private fields have been enabled for your next response.

Thanks,
Shane

#1271949

Hmm, this doesn't seem to be a Private reply, but since it's a staging site, not a big deal.

WP Page Edit: hidden link
Page not working as expected: hidden link

Thanks,
Jeff
------------

#1271977

Shane
Supporter

Languages: English (English )

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

Hi Jeff,

Thank you for the credentials.

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.

Please let me know and we can go from there.

Thanks,
Shane

#1271985

Hi Shane -

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..."

Thanks,
Jeff
------------

#1272011

Shane
Supporter

Languages: English (English )

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

Hi Jeff,

Not sure how this was working before but from what I can see it shouldn't have.

That is because these fields here

℅ [types field="treasurer-first-name"][/types] [types field="treasurer-last-name"][/types]<br />
[types field="treasurer-street-address"][/types]<br />
[types field="treasurer-city"][/types], [types field="treasurer-state"][/types] [types field="treasurer-zipcode"][/types]</span><br /><br /><span style="font-size:16px;">[types field="treasurer-email"][/types]<br />
Ph: [types field="treasurer-phone"][/types]

They are not on the post that you are calling the post body.

Thanks,
Shane

#1272015

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.

Jeff
------------

#1272755

Shane
Supporter

Languages: English (English )

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

Hi Jeff,

Yes it seems being in the conditional statement is breaking the shortcode.

Would you mind if I grab a copy of the site to see if this exact same issue occurs for me ?

I believe I know the cause of the issue but I want to ensure that i'm able to replicate on my end.

Thanks,
Shane

#1272943

Hi Shane -

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.

Jeff
------------

#1272963

Shane -

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.

Cheers,
Jeff
------------

#1272977

Shane
Supporter

Languages: English (English )

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

Hi Jeff,

The memory limit is what I wanted to test.

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.

Thanks,
Shane

#1272985

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.

Thx,
Jeff
------------

#1272989

Shane
Supporter

Languages: English (English )

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

Hi Jeff,

In simple terms you are calling this page here
hidden link

With the content template. Is it that the page is suppose to display the body of a specific post itself ?

Please let me know as we need to pass the post ID into the body code as well.

Thanks,
Shane

#1272993

Hey Shane -

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
------------

#1272995

Shane
Supporter

Languages: English (English )

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

Hi Jeff,

There isn't a way to really avoid this if your client has access to the CPT.

Plus you want it to be dynamic. Is it that there is a specific person info that should always be displayed ?

If it is a specific person and the user deletes it, not much we can do here. It would probably be best to let them know not to delete the post.

Thanks,
Shane