Support

Home Forums Event Espresso Premium Display event_cost as Custom Field when creating Custom Post Type from event

Display event_cost as Custom Field when creating Custom Post Type from event

Posted: March 1, 2014 at 1:04 am


Antony HILF

March 1, 2014 at 1:04 am

Hi,

I’d like the price of the event to show as a custom field when I’m creating a new post with the Custom Post Type function enable as it’s not showing by default. I kinda look in a couple of files and if I understand correctly, I should be able to add_post_meta in the insert_event.php file but I can’t get to make it work… Could you help me please?

I am using event-espresso 3.1.36 with wordpress 3.7.

Thank you!


Tony

  • Support Staff

March 3, 2014 at 4:05 am

Hi Anthony,

Whilst it is possible to add the event_cost to the post meta due to the fact that events can have multiple prices it is a little more complicated than adding something like:

add_post_meta($post_id, 'event_cost', $event_cost);

However we do have the EVENT_PRICE shortcode which will display the specified price for an event.

For example:

[EVENT_PRICE event_id=1 number=0]

Will pull the 1st price from the event with ID = 1

You could use this within the template (if you have the event ID) to display the price using:

<?php echo do_shortcode('[ESPRESSO_REG_PAGE event_id="'.$event_id.'"]');?>

Or you could event use that shortcode to place the value in the event meta if you prefer (although likely best within the template itself)

Does that help?


Antony HILF

March 13, 2014 at 8:13 am

Sorry for the long reply! I ended up using the shortcode as you suggested. Thanks a lot for your reply!

The support post ‘Display event_cost as Custom Field when creating Custom Post Type from event’ 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