Skip Navigation

[Resolved] Edit Post Link when using an Elementor Template

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

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 6 replies, has 2 voices.

Last updated by filipeC 3 years, 9 months ago.

Assisted by: Nigel.

Author
Posts
#1676853

I built a rather complicated template in Elementor for displaying one of my custom post types. I am trying to add Edit Section buttons that link to Toolset Edit Post forms. I set the button to the following shortcode:

[toolset-edit-post-link content_template_slug="edit-shipwreck-basic-information"][/toolset-edit-post-link]

But this returns a "Oops! Page not found." The URL of this error page references the correct content template ID number, so I am not sure what I am doing wrong.

Also, where do I find the slugs for the content templates? They are not listed in the sidebar under "Document" when editing the template like they are for pages.

#1677419

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Screenshot 2020-06-26 at 07.57.15.png

If you make the template to hold the edit form using the block editor then the slug isn't shown, it's shown when editing templates with the classic editor.

It should be straightforward to guess the slug from the template title, but the safest alternative is to generate the shortcode for the edit post link using the Toolset Forms button rather than setting it up manually. Editing any page/post with a classic editor would have the Toolset Forms button available, but if you are using the block editor you can insert a Classic block and you'll find the Toolset Forms button available (behind a Forms icon, see the screenshot). You can use this to generate the correct shortcode then discard the block.

(I realise this is somewhat clunky, an upcoming dev cycle will provide a major simplification of the edit forms workflow.)

I suspect the problem you are facing is that it sounds like you are using an Elementor button block. This probably doesn't parse shortcodes, and so the href for the button link doesn't have a meaningful URL (you should be able to check the markup on the front end using your browser dev tools).

It should be generating a URL which is the normal URL of the post itself with the content-template-id parameter appended.

One gotcha that you should be aware of using edit forms when you create your post templates with Elementor rather than with Toolset is that the edit form replaces the post content. In a Toolset template that would be everything, but with Elementor it is only the part where you insert a Post Content module, the rest of your template will still be shown.

#1678039

It should be straightforward to guess the slug from the template title, but the safest alternative is to generate the shortcode for the edit post link using the Toolset Forms button rather than setting it up manually.

This really ought to be visible somewhere, because it's possible to change the name of the templates after creating them. I can get the ID number of the template, but that's not what your shortcode uses. Can I request that this feature be added in a future update?

I actually solved the bulk of my problem this using the solution in this thread: https://toolset.com/forums/topic/adding-toolset-based-post-edit-form-in-elementor-powered-site/

This let me put the form in a new page and redirect the user there, bypassing the entire issue of Toolset needing to replace the Post Content module to show the form.

I also added an attribute to the function that let me specify the form in the shortcode:

<?php
/**
 * Creates a shortcode to pull up the specified edit post form.
 */

toolset_snippet_security_check() or die( 'Direct access is not allowed' );

// Put the code of your snippet below this comment.
function func_display_post_edit_form( $atts ) {
	$a = shortcode_atts( array(	'form-slug' => '' ), $atts );
	if(isset($_GET['post_id'])){
      if(isset($a['form-slug'])){
       return do_shortcode("[cred_form 
       	form='".$a['form-slug']."' 
        post='".$_GET['post_id']."']");
      }else{
      	return "No form slug specified";
      }
	}else{
       return "No Posts found to Edit Or Update";
   }
}
add_shortcode('display_post_edit_form', 'func_display_post_edit_form'); 

I haven't gotten the Elementor button itself working, but I can live with just a text link that says "Edit Section"

#1680053

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

It's safer to use slugs than IDs because the IDs can change when migrating sites.

In an upcoming dev cycle we will be overhauling the edit forms workflow to make the use of templates invisible, and I've just commented on the internal tickets to make sure we don't overlook any side effects for when using page builders, including Elementor.

Thanks for sharing your solution.

You could achieve something similar without registering the custom shortcode, by inserting the cred_form shortcode directly and using the wpv-search-term shortcode (https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-search-term) to get the URL parameter to populate the post attribute.

#1680645

1. I'm not saying you should use IDs instead of slugs, I'm simply requesting that the slug of content templates be visible somewhere in the backend. I can't just assume that I can guess the slug of the template from the name, because the name can be changed and I'm not the only one who works on this site.

2. Okay great.

3. Hm okay. I think I'll stick with the custom shortcode as it lets me set custom error messages

#1681917

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Sorry, I thought you meant you wanted to use the ids rather than the slugs.

The comments I made on the tickets for changing the edit workflow include making sure the template slug is visible (on the post edit screen in the document tab, as with general posts) in case the shortcodes need to be manually written anywhere, so that should cover this.

#1682733

My issue is resolved now. Thank you!

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