Support

Home Forums Event Espresso Premium ld+json Event Description displays shortcodes

ld+json Event Description displays shortcodes

Posted: March 9, 2020 at 3:54 pm

Viewing 3 reply threads


jestmurd

March 9, 2020 at 3:54 pm

The issue I am having is that I have to use shortcodes to display dynamic content on our events and when this is output through the ld+json Schema Data it outputs the Shortcode instead of executing and then displaying.

Is there a workaround that I can use to make this work. Is there a hook or snippet of code that I can use to make it execute the shortcode before outputting the description.

Thanks again,


Josh

  • Support Staff

March 9, 2020 at 4:06 pm

Hi,

There is a filter hook:

FHEE__EEH_Schema__add_json_linked_data_for_event__template_args

here’s a link to its source on GitHub for your reference:

https://github.com/eventespresso/event-espresso-core/blob/master/core/helpers/EEH_Schema.helper.php#L89


jestmurd

March 16, 2020 at 1:22 pm

Sorry I am still a bit of a beginner when it comes to this. Can you provide an example of using this to modify the description.

Thanks again for the awesome support.


Josh

  • Support Staff

March 19, 2020 at 4:02 pm

Hi,

At a minimum you’re looking to replace this:
$template_args['event_description'] = wp_strip_all_tags($event->short_description(200));

with something like this:

$template_args['event_description'] = wp_strip_all_tags($event->description_filtered());

So your code will look like this:

add_filter(
    'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args',
    'my_custom_json_linked_data_function',
    10,
    3
);
function my_custom_json_linked_data_function(
    $template_args,
    $event,
    $VNU_ID
) {
    $template_args['event_description'] = wp_strip_all_tags(
        $event->description_filtered()
    );
    return $template_args;
}

You can add the above to a functions plugin or, if available, into your WordPress child theme’s functions.php file.

Since I do not know what your shortcode outputs, there’s a possibility that something output by the shortcode should not be included within ld+json markup. It’d be good to check using the structured data testing tool.
https://search.google.com/structured-data/testing-tool/u/0/

Please also note that Google only shows a snippet of the full description.

Viewing 3 reply threads

The support post ‘ld+json Event Description displays shortcodes’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso