Support

Home Forums Event Espresso Premium Showing Event Meta in Custom Post Type Template

Showing Event Meta in Custom Post Type Template

Posted: April 15, 2013 at 1:37 pm

Viewing 3 reply threads


Michael Chasse

April 15, 2013 at 1:37 pm

I’m creating an upcoming event list using custom post types and have moved the page-event_list and single-espresso_event PHP files to my child theme location and made some minor adjustments to get them to display as I’d like.

I have created custom event metaboxes for a event_highlights, event_level and would like to include this information on my custom post types but am having no luck.  I have tried using the suggested syntax in my template files:

<?php echo do_shortcode(‘[EE_META type=”event_meta” name=” event_level”]’); ?>

but get no results.

What am I doing wrong and what can I do to make this functionality work?


Dean

April 16, 2013 at 4:56 am

Hi Michael,

OK, so that shortcode wont work on anything other than an event.

What you need to do is a little more complex.

In your template (so probably single.php of the theme since you are dealing with posts) you need to add the following or something similar.

$get_ee_post_meta = get_post_meta(get_the_ID(), event_meta, true); //get the meta data from the post

$converted_data = unserialize($get_ee_post_meta); //convert it from serialised data into an array so we can get what we need

//var_dump($converted_data); //just for testing purposes

echo $converted_data['event_level']; //echo out the keys value, so in this case the event_level
echo $converted_data['another_meta_key_name']; // and becuase it has all the post meta in a variable we can pull out whatever we need from it.
// etc etc


Michael Chasse

April 23, 2013 at 4:41 pm

You saved my day… Messed with this for much of the day before posting and woke up the next morning, with both my questions answered, and by you.  Thanks Dean!

I carry this a bit further and outputted the 6 fields in my custom post types.  Works like a charm.


Dean

April 24, 2013 at 12:46 am

You’re welcome!

Viewing 3 reply threads

The support post ‘Showing Event Meta in Custom Post Type Template’ 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