Skip Navigation

[Resolved] custom shortcode not working

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 2 replies, has 1 voice.

Last updated by charlesR-4 2 days, 17 hours ago.

Assisted by: Minesh.

Author
Posts
#2824134
toolset venuelink troubleshooting.jpg

I am trying to use a custom shortcode in a View. I have done this before without a problem, but for some reason this one is not working.

My test page is here: hidden link
In the screenings box after the venue name, it is outputting [venuelink] rather than doing that shortcode.

I have registered this shortcode in settings under "Third-party shortcode arguments." There is another custom shortcode in this View that is working as intended, so I'm not sure why this one is not.

Any help would be appreciated.

#2824201

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

That is really starnge.

Can you please tell me where you added the custom shortcode code?
- Within your theme's functions.php?

Can you please send me admin access details and let me review whats going wrong with your setup.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2824477

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Just FYI - Toolset also offers "Custom Code" section where you can add and manage the custom code for your site.
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/

I've moved the code to "Custom code" section:
- hidden link

Now, The issue was, your current code was looks like as follows which was added to functions.php file:

function venuelink() {
	$venue_id = get_post_meta(get_the_ID(), '_EventVenueID', true); // put the venue post ID in a variable
	if ($venue_id != '') { // if the ID exists...
		$venue_website = get_post_meta($venue_id, '_VenueURL', true); // ...get the website URL field
		echo '<br><a href="' . $venue_website . '" class="venue-link">Venue information...</a>'; // create the link
	}
	add_shortcode('venuelink', 'venuelink');
}

As you many noticed, the add_shortcode line added within the function "venuelink" and that was not correct. I've corrected it and put the add_shortcode line after the closing bracket of the function "venuelink". So it looks now as given under:

function venuelink() {
	$venue_id = get_post_meta(get_the_ID(), '_EventVenueID', true); // put the venue post ID in a variable
	if ($venue_id != '') { // if the ID exists...
		$venue_website = get_post_meta($venue_id, '_VenueURL', true); // ...get the website URL field
		echo '<br><a href="' . $venue_website . '" class="venue-link">Venue information...</a>'; // create the link
	}
	
}
add_shortcode('venuelink', 'venuelink');

I can see now shorcode working as expected.

#2824482

Of course it was something as simple as a misplaced bracket. Thank you for your time. I really appreciate the help.