Skip Navigation

[Resolved] Custom field title as parameter with external plugin shortcode

This support ticket is created 6 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 10 replies, has 2 voices.

Last updated by katjaL 6 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#625352

I have an artist database (Toolset cpt, "artist") and on artist single view (Toolset content template) I want to show current artist's events. The events and artists aren't related, but the event's category is named the same way as the artist's name. So we have an artist called (post title) "Player Ben" and an event with category "Player Ben".

I've looked through this document, but can't figure out how to do it:
https://toolset.com/documentation/user-guides/shortcodes-within-shortcodes/

I would think I need to have toolset post title as an argument to the calendar shortcode. This doesn't work:
[ecs-list-events cat='[wpv-post-title]']
this works: [ecs-list-events cat='player-ben']

Any idea how to proceed? Thank you!

#625421

Hi, the wpv-post-title shortcode will return the full post title like "Player Ben", but I think you want the post slug like "player-ben". You can use the wpv-post-slug shortcode to get that value. Try this:

[ecs-list-events cat='[wpv-post-slug]']

The slugs of the post and category term must be identical.

#625427

Thank you Christian. Unfortunately this doesn't work either. I get

There are no upcoming events at this time.‘]

Though I do have events. And there is this '] at the end hinting something is wrong.

#625452

This events shortcode may not be capable of interpreting nested shortcodes in its attributes. Try this to make sure the post slug is correct first:

Slug: [wpv-post-slug], <br />
Shortcode 1: [ecs-list-events cat='[wpv-post-slug]'], <br />
Shortcode 2: [ecs-list-events cat='player-ben'], <br />
#625457

Yes it seems so. I get:

Slug: player-ben,
Shortcode 1: There are no upcoming events at this time.‘]
Shortcode 2: list of events of Player Ben

Hmm... so what is the direction from here?

#625958

Okay so that indicates the slug is outputting the correct value, but the ecs-list-events shortcode does not accept it. Let's try to fix that. Go into your child theme's functions.php file and add the following code:

function ts_do_ecs_list_events_func($atts) {
  $a = shortcode_atts( array(
      'cat' => ''
  ), $atts );
  ob_start();
  do_shortcode('[ecs-list-events cat="' . $a['cat'] . '"]');

  return ob_get_clean();
}
add_shortcode("ts_do_ecs_list_events", "ts_do_ecs_list_events_func");

Then add the new shortcode like this:

Slug: [wpv-post-slug], <br />
Shortcode 1: [ecs-list-events cat='[wpv-post-slug]'], <br />
Shortcode 2: [ecs-list-events cat='player-ben'], <br />
Shortcode 3: [ts_do_ecs_list_events cat="[wpv-post-slug]"], <br />

If this does not work, I'll need to take a closer look.

#626084

The result in frontend is:

Shortcode 3: ”],

The previous results are like before.

#626259

Okay at this point, I think it makes the most sense for me to log into your wp-admin area and see what's going on. I may need to make a clone of your site using the Duplicator plugin so I can run some additional tests without breaking your live site. If that's okay with you, please provide login credentials in the private reply fields here.

#626297

Okay this is strange. I was able to fix it on my local copy by adding the shortcode to the Teksti cell above the tabs, and hiding it with CSS:

<div style="display:none;">[ecs-list-events cat="[wpv-post-slug]"]</div>

This is a temporary option while my 2nd tier support team does some additional investigation. Please stand by and I will update you when I have some new information to share.

#629123

Hi, it appears there is a broken link in the Kuva tab that is causing problems:

<a href="[wpv-post-featured-image size=">[wpv-post-featured-image size="full"]</a>

Once the broken href is fixed, things start working as expected in our clone environment. Can you check that and confirm on your end?

#629194

Hi Christian, I changed the code, still I couldn't get the events of particular category show. Now also this is urgently going under production and client already decided not to show the calendar events in this view at all. So I can't continue testing, I had to delete it in this point. But thank you very much of your help!