Support

Home Forums Event Espresso Premium Custom Fields

Custom Fields

Posted: September 5, 2013 at 3:52 am


Klaus M

September 5, 2013 at 3:52 am

How can i retrieve my CUSTOM FIELD value? Tried to insert the customfield name used on the EE page, but nothing happened ;( thanks!

<?php
$key_1_value = get_post_meta( get_the_ID(), ‘CUSTOMFIELD’, true );
// check if the custom field has a value
if( ! empty( $key_1_value ) ) {
echo $key_1_value;
}
?>


Tony

  • Support Staff

September 5, 2013 at 4:11 am

Hi Klaus,

So that we can give you the best answer, can I ask what it is your trying to do?

From previous posts it looks like your using the CPT feature, alot of the events detail are already available as post meta.

Do you have an example of what your trying to achieve?


Dean

September 5, 2013 at 4:16 am

Hello,

Currently events are not true custom post types so get_post_meta will not work. Please use this shortcode instead

https://eventespresso.com/wiki/shortcodes-template-variables/#ee-meta


Klaus M

September 5, 2013 at 5:23 am

That works with standard fields, not with my ee_subline custom field (or existing custom fields) ;(

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


Dean

September 5, 2013 at 6:18 am

Did you change the name= to the field name?

E.g. if my custom field is “deans field” then the shortcode would be

<?php echo do_shortcode(โ€˜[EE_META type="event_meta" name="deans field"]โ€˜); ?>


Klaus M

September 5, 2013 at 6:23 am

yes, that’s why i tried it with your existing “event_hashtag” and added a value, but even that does not work ๐Ÿ™


Josh

  • Support Staff

September 5, 2013 at 8:10 am

Hi Klaus,

I’m wondering if the $event_meta variable is set on the template you are working with. Which template are you working with?


Klaus M

September 5, 2013 at 2:56 pm

thats my own template, build from scratch. what does the template have to have? other meta fields like the date or event_id are showing up using the shortcode?!


Josh

  • Support Staff

September 5, 2013 at 9:35 pm

Hi Klaus,

Since we didn’t build your template that you built from scratch, I really don’t see how we can support it. I can advise checking the example templates out that are located in post-type-samples to see how they handle the variables.


Klaus M

September 6, 2013 at 2:22 am

RESOLVED! Thanks for your awesome support! Really great!

The support post ‘Custom Fields’ 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