Support

Home Forums Event Espresso Premium Change shortcode to variable

Change shortcode to variable

Posted: February 10, 2014 at 1:39 pm


devjenifer

February 10, 2014 at 1:39 pm

Hi,
question from a non-programmer:
How do I use this shortcode in a template?
[EVENT_CUSTOM_VIEW template_name=”events-table” limit=”4″].


Tony

  • Support Staff

February 10, 2014 at 2:55 pm

Hi devjenifer,

Wrap that shortcode within the do_shortcode() function so within the Template it would become something like this:

do_shortcode('[EVENT_CUSTOM_VIEW template_name="events-table" limit="4"]');

Hope that helps.


devjenifer

February 10, 2014 at 4:00 pm

Thanks Tony, I tried your suggestion, but I do not get a list of the latest four events.

The shortcode worked on a static page, but I want to place the latest four events in a template. Could I use something like:
<?php echo $event_id…correct syntax to show 4 ?>


Dean

February 11, 2014 at 12:18 am

Hi,

If you are wanting to add the shortcode to a template then Tony’s code is correct. You do need to echo it out though liek so

<?php echo do_shortcode('[EVENT_CUSTOM_VIEW template_name="events-table" limit="4"]'); ?>

This can be added to theme templates such as single.php.


devjenifer

February 11, 2014 at 3:38 am

yep, worked perfectly, thanks Dean!


Tony

  • Support Staff

February 11, 2014 at 3:44 am

Sorry Jenifer,

Didn’t think to mention to echo!

Anyway, glad Dean spotted it and got you working 🙂


devjenifer

February 11, 2014 at 4:04 am

np, you guys rock!

The support post ‘Change shortcode to variable’ 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