Tell us what you are trying to do? I'm trying to add an edit link to a venue custom post type, but the post type doesn't have a content template, but a php template instead. I've followed the instructions listed below but, in the last instruction, instead of adding the link to the single post content template, I need to add it to a php template.
The code I wish to add is:
{!{toolset-edit-post-link content_template_slug='edit-club-template' target='self'}!}Edit %%POST_TITLE%%{!{/toolset-edit-post-link}!}
I've tried adding it to a page, then linking to that page, but I just get a blank page.
Is there any documentation that you are following? https://toolset.com/documentation/getting-started-with-toolset/publish-content-from-the-front-end/forms-for-editing/
Is there a similar example that we can see? hidden link
What is the link to your site? hidden link
Any thoughts or ideas greatly appreciated as always.
Kind regards
James
Hi, if I understand correctly you want to add an Edit Post link in a PHP template. A toolset-edit-post-link shortcode added in wp-admin will produce on the front-end a simple link tag with href URL in the following format:
<em><u>hidden link</u></em>
With that in mind, you could echo a basic HTML link using this format in PHP, instead of using the toolset-edit-post-link shortcode:
echo "<a href='<em><u>hidden link</u></em>;" . get_the_title( $post_id ) . "</a>";
Change cpt-slug to your post type slug, change post-slug to the post slug, and change 12345 to the numeric ID of the Content Template containing your edit post Form. The get_the_title( $post_id ) bit is just an example of retrieving the post title, you may need to alter the post ID code depending on how your PHP template is set up.
Let me know if I misunderstood what you want to accomplish and I can offer some different feedback. Thanks!
Hi Christian,
Many thanks for your quick reply. Yes, you've understood that perfectly. My only question is what to use for the post slug as that will be dynamic (the name of the club).
My shortcake looks like:
echo "hidden link">" . get_the_title( $post_id ) . "";
An example club link
hidden link
If I manually ass /sxs-racing/ as the post-slug the link works, so what would be the best shortcode to use in it's place.
Apologies as I should know this!
Kind regards
James
I've almost done it.
This:
<?php echo ""; ?>
Give me this:
hidden link
I just need to remove (sanitise?) the %20's.
You can access the post's slug in PHP as a post field called 'post_name':
$post_slug = get_post_field( 'post_name', $post_id );
Then use $post_slug in your URL instead of get_the_title(). A list of those post member variables like slug, title, excerpt, etc. can be found here:
https://codex.wordpress.org/Class_Reference/WP_Post#Member_Variables_of_WP_Post
Perfect! That did the trick.
For reference in case anyone else has the same issue, here's what I used in the end:
<?php echo "Edit " . get_the_title( $post_id ) . ""; ?>
Many thanks for your help.
Kind regards
James