Skip Navigation

[Resolved] Split: Using shortcode within shortcode in Elementor

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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 6 replies, has 2 voices.

Last updated by julieM-9 11 months, 1 week ago.

Assisted by: Waqar.

Author
Posts
#2595255

I was able to sort through that issue.

But now as I'm working on the post edit form, I'm running into issues.

I'm using elementor so I'm using the shortcode: [cred_form form='post-edit-startups' post='[wpv-search-term param=“post_id”]

The link to edit the post is: hidden link;

It worked for minute and then started displaying: "Form type and post type do not match" -- I've looked through every post on here about that error, and normally it's because the category wasn't matched correctly, or wordpress needed updates. All of my plugins are up to date, and it's mapped correctly.

Is there any other troubleshooting tips?

#2595265

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Looks like the Elementor page builder is having difficulty handing the shortcodes within the shortcode.
(i.e. where one shortcode's output is used as the attribute of another shortcode)

Here is a workaround that you can use:

1. You can register a new custom shortcode, which can get the target post ID from the URL parameter, use it in the form's shortcode, and then return the form's output, all using a single shortcode:


add_shortcode('custom_edit_form_shortcode', 'custom_edit_form_shortcode_func');
function custom_edit_form_shortcode_func($atts) {

	$a = shortcode_atts( array(
		'form' => '',
		'param' => '',
	), $atts );

	ob_start();
	echo do_shortcode('[cred_form form="'.$a['form'].'" post="'.$_GET[$a['param']].'"]');
	return ob_get_clean();
	
}

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.

2. After that, you can use this new shortcode in the Elementor environment like this:


[custom_edit_form_shortcode form='post-edit-startups' param='post_id']

Please note that this new shortcode accepts two parameters:

form: you'll provide the slug of the name or slug of the target form
param: you'll provide the URL parameter from which to get the target post's ID.

I hope this helps and let me know how it goes.

regards,
Waqar

#2595371

I did that, and it's still showing the same error.

It's weird, because it worked for a bit before it started giving me this error.

And it works fine if I reference the exact post, which goes back to your point of it not recognizing a shortcode within a shortcode.

Could it take some time for it to implement the code?

#2596191

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

> Could it take some time for it to implement the code?

- Unless some aggressive cache or code optimization is in place, the code should start working right away.

Can you please share temporary admin login details, along with the link to the page where you're trying to use this shortcode? I'll be able to troubleshoot and suggest the next steps, accordingly.

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

#2597217

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for sharing the access details.

The edit link on the 'My Account' page, was not passing the target post's ID correctly.

In the Elementor template 'Author Loop', that generates this edit link, the link used was:
hidden link;

But Elementor was not processing the [wpv-post-id] shortcode in this case and the post's ID was not getting included.

I changed that static link to 'Shortcode' and in the shortcode field included the 'wpv-post-url' and 'wpv-post-id' to generate the edit link:
( screenshot: hidden link )


[wpv-post-url item='10398']?post_id=[wpv-post-id]

Note: '10398' is the ID of the 'Edit Listing' page.

#2597409

That's great, I didn't realize you could put a shortcode on a button.

Thank you so much!!

#2597411

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.