Support

Home Forums Event Espresso Premium Nesting Shortcode for Event ID

Nesting Shortcode for Event ID

Posted: January 15, 2014 at 2:52 pm

Viewing 2 reply threads


novaopen

January 15, 2014 at 2:52 pm

I’m trying to nest a shortcode within [ESPRESSO_CART_LINK event_id=”[SHOW_EVENT_ID]-312″ anchor=”Add to Cart”] to automatically select the current record event_ID. The second value is a constant.

<code>//Returns event_id value for the current record.
//Best used nested with other shortcodes

//[SHOW_EVENT_ID]
function show_event_id_func( $atts ){
	return $event_id;
}
add_shortcode(&#039;SHOW_EVENT_ID&#039;, &#039;show_event_id_func&#039;);</code>

Tried it a lot of ways (e.g., echo, enclosed in <?php ?>. I think I’m calling the wrong value since it doesn’t work as a standalone either.

NOTE: I started a thread on this at https://eventespresso.com/topic/replacing-add-to-cart-link/ but the subject has changed quite a bit. I hadn’t heard back so I have reposted.


novaopen

January 15, 2014 at 2:55 pm

The last line is actually:

add_shortcode(‘SHOW_EVENT_ID’, ‘show_event_id_func’);


Josh

  • Support Staff

January 15, 2014 at 7:17 pm

Hi Michael,

You’ll need to define your $event_id variable in your custom function, or use your cart shortcode in a do_shortcode and use $event_id within the loop ($event_id is already defined for the loop in registration_page.php).

Viewing 2 reply threads

The support post ‘Nesting Shortcode for Event ID’ 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