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.
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.
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');