Support

Home Forums Event Espresso Premium [ESPRESSO_TICKET_SELECTOR] on archive-espresso_events.php

[ESPRESSO_TICKET_SELECTOR] on archive-espresso_events.php

Posted: May 9, 2017 at 11:11 am


Jerry

May 9, 2017 at 11:11 am

I’m using [ESPRESSO_TICKET_SELECTOR] in my own customized version of archive-espresso_events.php. The shortcode is in a WordPress loop, and it seems to output the correct results, but I’m getting this error message (with WP_DEBUG enabled) for all events after the first one:

Warning: extract() expects parameter 1 to be array, string given in /home/xxxxxxx/public_html/wp/wp-content/plugins/event-espresso-core-reg/shortcodes/espresso_ticket_selector/EES_Espresso_Ticket_Selector.shortcode.php on line 66

Am I doing this right? Is there anything wrong with using multiple instances of that shortcode on a page, or with using it in a loop?

Thanks for your help.


Josh

  • Support Staff

May 9, 2017 at 12:14 pm

Hi there,

In most cases you shouldn’t use the shortcode within PHP code because it’s likely you’ll run into dependency issues. So instead of
<?php echo do_shortcode( '[ESPRESSO_TICKET_SELECTOR]' ); ?>

You can do this:

<?php $event_obj = $post->EE_Event;
if ( $event_obj instanceof EE_Event ){
espresso_ticket_selector( $event_obj ); 
}
?>


Jerry

May 9, 2017 at 12:35 pm

Hmm, when I paste your code into my template, I get: “This page isn’t working”

I pasted your code in place of what I had there originally, which was:

<?php echo do_shortcode( ‘[ESPRESSO_TICKET_SELECTOR]’ ); ?>


Josh

  • Support Staff

May 9, 2017 at 12:41 pm

Quite likely because the $post object isn’t set (or is set by another variable). Can you post a gist of the template you are working with so we can see the code in context?


Jerry

May 9, 2017 at 12:48 pm

I never created a gist before, so pardon me if I didn’t do it right:

https://gist.github.com/bjtalbot1/15c0a82246887dc922959aa270361980


Josh

  • Support Staff

May 9, 2017 at 1:08 pm

OK this should work for you in place of where you have the ticket selector shortcode:

<?php global $post;
$event_obj = $post->EE_Event;
if ( $event_obj instanceof EE_Event ){
	espresso_ticket_selector( $event_obj );
}
?>


Jerry

May 9, 2017 at 2:22 pm

Yes, that worked, thanks so much!! 🙂

The support post ‘[ESPRESSO_TICKET_SELECTOR] on archive-espresso_events.php’ 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