Skip Navigation

[Resolved] Adding toolset-edit-post-link shortcode to php template renders the shortcode text

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

Problem: I have created a custom PHP template file for a CPT. When I try to include a Toolset Edit Post Link shortcode, the shortcode is written out to the page instead of displaying the link.

Solution: If you're not using Layouts on your site, disable the plugin. Then the shortcode should work in a PHP template like this:

echo do_shortcode('[toolset-edit-post-link content_template_slug="user-edit-artist-band"]Edit[/toolset-edit-post-link]');

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#toolset-edit-post-link

This support ticket is created 5 years, 11 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 6 replies, has 2 voices.

Last updated by frankN-3 5 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#687734
test.png

I am trying to: add an edit post link to a template .php page

I've added the following to the template file

<?php echo do_shortcode('[toolset–edit–post–link content_template_slug="user-edit-artist-band"]Edit[/toolset–edit–post–link]'); ?>

Link to a page where the issue can be seen: hidden link

I expected to see: an edit link

Instead, I got:
When logged in as admin the actual shortcode text shows on the page. When not logged in, nothing shows

#688229

Hi, it looks like you're using Layouts on your site. If you're using Layouts, the syntax is a bit different:

echo do_shortcode('[toolset–edit–post–link layout_slug="user-edit-artist-band"]Edit[/toolset–edit–post–link]');

Create a layout and insert a Post CRED Form cell that includes your Edit CRED form. Do not assign the Layout to any post type or archives. Update the slug in the code above to match the slug of the Layout, and test again. Let me know if this does not resolve the problem.

#688287

Thanks. The Layouts plugin is installed but not being used on the site. I'm currently using Views.

#688364

Oh okay, you'll need to deactivate the Layouts plugin in that case. Otherwise, you will not be able to use Content Templates to hold your CRED forms.

#688446

Most of the list pages were built pre Layouts and I haven't quite gotten the hang of Layouts yet.

I just deactivated Layouts but the original issue still exists. Thanks

#692114

This is strange but I think it's working now. I went to the post in wp-admin and used the GUI to insert an edit link. Then I cut that link out and pasted it in the template PHP file's do_shortcode call, and now it seems to be working correctly. The strange thing is I can't see any difference between this code and the code that was in place before:

echo do_shortcode('[toolset-edit-post-link content_template_slug="user-edit-artist-band"]Edit[/toolset-edit-post-link]');

Perhaps there was a character encoded improperly or something cached by a caching plugin. At any rate, I updated the template file and it seems to be working now. Please be sure to download the updated single-organizer.php file to your local file system.

#692619

You got it. Thanks. Something I never would have thought of but a great tool to use in the future.

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