Home › Toolset Professional Support › [Resolved] toolset_edit_post_link shortcode not working inside Elementor Post Template
Problem:
Elementor is used to make templates for single custom posts, while Toolset Forms is used to make forms to edit the posts. When clicking the edit links the post is shown, not the edit form.
Solution:
It is necessary to include the Post Content module in the Elementor Pro template, which will be replaced by the edit form when editing the post using the Toolset Form.
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 |
---|---|---|---|---|---|---|
- | 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+00:00)
Tagged: Toolset Forms
This topic contains 12 replies, has 2 voices.
Last updated by Furlan 5 years, 6 months ago.
Assisted by: Nigel.
I took the following code from Toolset Classified Sites. It is used to show a menu in Listings.
<span class="product-tech-info"> [wpv-conditional if="('[wpv-current-user info='id']' eq '[wpv-post-author format='meta' meta='ID']') OR ('[wpv-current-user info='role']' eq 'administrator')"] <span class="dashicons dashicons-welcome-write-blog text-info"></span> [toolset-edit-post-link layout_slug="ad-single-edit" class="text-info"]Editar[/toolset-edit-post-link] <span class="dashicons dashicons-trash text-danger"></span> [cred_delete_post_link action='delete' class='listing-trash-button cred-refresh-after-delete text-danger' text='Borrar' redirect='3978' message='¿Está seguro que desea borrar este anuncio?' message_show='1' class='cred-refresh-after-delete'] [wpv-conditional if="( '[cred-post-expiration format='U']' ne '' )"] <span class="expiration-date"> <span class="dashicons dashicons-calendar-alt"></span> [wpml-string context="wpv-views"]Expira:[/wpml-string] [cred-post-expiration format='d-m-Y'] </span> [/wpv-conditional] [wpv-conditional if="'[wpv-post-status]' eq 'draft'"] <strong class="add-expired">[wpml-string context="wpv-views"]¡Este anuncio ya no está disponible![/wpml-string]</strong> [/wpv-conditional] [/wpv-conditional] </span>
I tried to replicate the code inside the template used to display my listings in the page. The problem is that I can't not Edit the post, since toolset edit_post_link shortcode appear to not work inside this instance.
The following is the error_log.php obtained in the page:
[11-Jun-2019 02:10:41 UTC] PHP Notice: Undefined index: url in /public_html/wp-content/plugins/ultimate-elementor/modules/image-gallery/widgets/image-gallery.php on line 1829 [11-Jun-2019 02:10:46 UTC] PHP Notice: Undefined variable: user_ip in /public_html/wp-content/plugins/post-views-counter/includes/counter.php on line 384 [11-Jun-2019 02:10:46 UTC] PHP Notice: Undefined variable: user_ip in /public_html/wp-content/plugins/post-views-counter/includes/counter.php on line 390 [11-Jun-2019 02:22:54 UTC] PHP Warning: Invalid argument supplied for foreach() in /public_html/wp-content/plugins/ultimate-elementor/modules/image-gallery/widgets/image-gallery.php on line 1783 [11-Jun-2019 02:24:03 UTC] PHP Notice: Undefined property: WP_Post::$filter in /public_html/wp-includes/class-wp-post.php on line 342 [11-Jun-2019 02:27:33 UTC] PHP Notice: Undefined variable: user_ip in /public_html/wp-content/plugins/post-views-counter/includes/counter.php on line 384 [11-Jun-2019 02:27:33 UTC] PHP Notice: Undefined variable: user_ip in /public_html/wp-content/plugins/post-views-counter/includes/counter.php on line 390 [11-Jun-2019 02:39:13 UTC] PHP Warning: filesize(): stat failed for /public_html/wp-content/uploads/sites/2/1970/01/bbfd2624fdb7b0fbb610390d6c8cce84-wpcf_133x106.jpg in /home/103707-78977.cloudwaysapps.com/drmjkqfgjr/public_html/wp-content/plugins/wp-optimize/includes/class-updraft-smush-manager.php on line 530
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi there
You have lots of errors reported in your debug log that you shared above, but none of them are from Toolset.
Try disabling ultimate-elementor, post-views-counter, and wp-optimize, which are responsible for the errors.
Also, in the code you shared above, the edit links look like they expect you to have an edit form inside a Layout template, but from your debug info it appears that you are not using Layouts.
Rather than copying and pasting the code from another site you should set up the post edit form from scratch, hosting it in a Content Template, and inserting the edit links using the Toolset Forms button so that they are generated correctly.
I suggest you review the documentation for post edit forms: https://toolset.com/documentation/getting-started-with-toolset/publish-content-from-the-front-end/forms-for-editing/
Hi Nigel,
You were right. I was doing many things wrong. Finally I've done inserted the toolset_edit_post_link shortcode into the elementor template, but when I click on it, the form used to edit the listing won't open.
I'd like you could take a look the code:
<span class="product-tech-info"> [wpv-conditional if="('[wpv-current-user info='id']' eq '[wpv-post-author format='meta' meta='ID']') OR ('[wpv-current-user info='role']' eq 'administrator')"] <span class="dashicons dashicons-welcome-write-blog text-info"></span>[toolset-edit-post-link content_template_slug='editar-anuncio' target='blank']Editar[/toolset-edit-post-link] <span class="dashicons dashicons-trash text-danger"></span> [cred_delete_post_link action='delete' class='listing-trash-button cred-refresh-after-delete text-danger' text='Borrar' redirect='3978' message='¿Está seguro que desea borrar este anuncio?' message_show='1' class='cred-refresh-after-delete'] [wpv-conditional if="( '[cred-post-expiration format='U']' ne '' )"] <span class="expiration-date"> <span class="dashicons dashicons-calendar-alt"></span> [wpml-string context="wpv-views"]Expira:[/wpml-string] [cred-post-expiration format='F j, Y'] </span> [/wpv-conditional] [/wpv-conditional] [wpv-conditional if="'[wpv-post-status]' eq 'draft'"] <strong class="add-expired">[wpml-string context="wpv-views"]¡Este anuncio ya no está disponible![/wpml-string]</strong> [/wpv-conditional] </span>
Any idea what could be wrong?
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
The code looks okay and I just tested edit links in Elementor templates on my own site and it was working okay.
Can I take a look at your site to see if I can spot the problem?
I will mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site, even though I don't intend to make any changes other than testing this very issue.
Can you also confirm:
- which edit form this is
- which Elementor template is used to display the posts, of which type?
Hi Nigel,
I think you forgot to mark the message as private.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Sorry, let me try again.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
There appear to be two problems.
The conditional shortcodes are not working, because the wpv-current-user shortcode doesn't appear to be working.
I added another text module immediately above the module where you conditionally insert the edit link to demonstrate.
Also, if you remove all of the conditionals and simply insert the edit link directly so that it should always display, the link works, inasmuch as it reloads the page with an added URL parameter to identify the content template which contains the edit form, but the form doesn't display, the post continues to display normally.
What should happen, and what happens on my own Elementor test site, is that Forms takes control of the page and displays the edit form in place of the post itself.
I don't know if this is a live site or just a test site.
Can you repeat these tests with all non-Toolset plugins de-activated and, if necessary, with a standard theme such as twentynineteen to see if you can identify any conflicts that cause these two issues, and let me know what you find?
Hi Nigel,
I did what you suggested, but I couldn't achieve the Edit Form to be triggered and displayed adequately. What I see is the current post being reloaded in a new window.
Actually this is not a live site, we are testing functionalities before launching site soon.
On my side [wpv-current-user info='role'] appears to work correctly.
Besides toolset_edit_post_link shortcode, is there another way to trigger de Edit Form for the current post, for instance, using a bootstrap button?
If the answer is no, what could I do to be able to edit the current post.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
The edit form works by reloading the page with a URL parameter to specify the content template that contains the edit form, and so you could construct such a link yourself if you wanted an alternative to the link generated by the tooset_edit_post_link shortcode.
But that wouldn't solve the underlying problem, namely that the edit form isn't displaying when such a link is clicked.
I think I'll need to take a copy of the site to install locally to do some more testing, and I may need to pass it to my colleagues if I can't determine the problem myself.
I'll update you again with my findings.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
I was unable to get the copy of your site to install locally so I went back in to look at your site.
Re-visiting the Elementor template for single anuncios, I believe the problem is that you have not included the Post Content module anywhere in the template.
The edit form works by replacing the post content, and if it is missing from the template there is nothing for it to replace.
It looks like you are not using the post content in the anuncios posts, but you need to include the Post Content module in the template in any case (even though it won't normally output anything, except when following the edit post link).
Can you try that?
Hi Nigel,
How could I include the Post Content module in the template?
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
I'm talking about the Elementor Post Content module, it's one of the first listed modules when editing the template with Elementor.
After Inserting Post Content Module in the template, finally Edit form was triggered in the same page.
It is not the perfect solution, since the Edit Form displays with other content already present in the page, but it is a medium resolution of my situation.