Support

Home Forums Event Espresso Premium ACF shortcodes not rendering in Event Espresso sidebar

ACF shortcodes not rendering in Event Espresso sidebar

Posted: December 28, 2018 at 12:44 pm


ICLE

December 28, 2018 at 12:44 pm

ACF Shortcodes are used in the Description field of the Event post.
Description is turned on in the sidebar as a display field.
The field shows unrendered ACF shortcodes, not the expected data.
How can I overcome this?

Example

You will see the | pipes on the left and where they are in the acf shortcodes in the sidebar in this example.

Am I outside of “the loop”? How does one get back in the loop?


Tony

  • Support Staff

December 28, 2018 at 1:59 pm

Hi there,

The widget doesn’t parse shortcodes by default, so you’ll need to make a change to the code used.

However, to clarify, on this event: https://iclega-attend.org/events/child_protection_seminar_2019/

Is this section from ACF? – http://take.ms/emddm

Or is it set within the excerpt?

The reason I’m asking is the numbers show on the widget for that event, which doesn’t really make sense if those are coming from ACF.


ICLE

January 2, 2019 at 7:29 am

I had typed in those values manually in the description field: for that event they are not coming from ACF.
Screenshot`

What changes will I need to make to the code in order for the widgets and for the listing page to show the ACF values per record?


Tony

  • Support Staff

January 2, 2019 at 9:11 am

Use this snippet:

https://gist.github.com/Pebblo/d0d5f485ae0599e56e20

You can add that to a custom functions plugin on your site, we have some documentation on creating one here:

https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/

Then change this line:

https://gist.github.com/Pebblo/d0d5f485ae0599e56e20#file-tw_custom_upcoming_events_widget-php-L379

To be: echo '<p style="margin-top: .5em">' . do_shortcode($desc) . '</p>';

Then, go to Dashboard -> Widgets.

The snippet I gave you adds a new widget called ‘Custom Event Espresso Upcoming Events’, use that in place of the original so that you can edit the code used (because it’s now in your custom plugin).

Does it work for you then?

  • This reply was modified 5 years, 3 months ago by  Tony.


ICLE

January 2, 2019 at 11:37 am

I have a couple of custom plugins I have made, and I think I will just add this code to the “general” one since this is a global thing I want to happen all the time. I will circle back when I have tested and launched. Thanks.


ICLE

January 2, 2019 at 12:28 pm

The rendering is occurring but it appears the data is all based on the record which is in the main part of the page…
I was hoping to get values from each record for each record shown in the list.
https://monosnap.com/file/aZN74ykcFpmCON99m2sEcQlTgdn22L
The values all appear to come from record 10103, not the respective records in the list…in the sidebar.


Tony

  • Support Staff

January 3, 2019 at 5:46 am

Yeah, the reason is that ACF is using the global post object to parse the shortcode, which at that time is the single EE event post.

Can you not use the ACF function get_field() to pull the value directly within the widget?

The other option is to pull the post object and replace the global $post object in the loop, then reset it when finished.

global $post;
$post = get_post($event->ID());

//output the content

wp_reset_postdata();


ICLE

January 3, 2019 at 9:12 am

Wow. I updated that and is seems to be working. I will test this a bit and let you know if I need more guidance. Thanks!


Tony

  • Support Staff

January 3, 2019 at 9:31 am

You’re most welcome.

The support post ‘ACF shortcodes not rendering in Event Espresso sidebar’ 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