Home Forums Event Espresso Premium Using Event Metadata

Using Event Metadata

Posted: August 7, 2020 at 4:15 pm


August 7, 2020 at 4:15 pm


I am trying to use custom fields to display custom info on events in the [ESPRESSO_EVENTS] list. I set up a one field called “Barcode” and input a value ‘12345’ but I can’t seem to figure out why it wont show for the event.

I have added the following code in content-espresso_events-shortcode.php
Code: <?php get_post_meta($post_id = the_ID(), 'Barcode'); ?>

It displays ‘6332’ on the event in the list. Every event I have has its own number displayed. Does EE4 support this function?


  • Support Staff

August 7, 2020 at 6:32 pm


You can make an adjustment to your code so it’s like this instead:

<?php echo get_post_meta( get_the_ID(), 'Barcode', true ); ?>

or to be safe, with a check for a value:

$keyvalue = get_post_meta( get_the_ID(), 'Barcode', true );
// Check if the custom field has a value.
if ( ! empty( $keyvalue ) ) {
    echo $keyvalue;


August 10, 2020 at 11:12 am

Thanks, worked perfectly!

I was wondering how I can get the key to show before the value. So I want it to show “Barcode: #####” instead of just the numbers.

Thanks in advance!


  • Support Staff

August 10, 2020 at 2:42 pm

Rather than just:

echo $keyvalue;

You would have:

echo 'Barcode:' . $keyvalue;

From the above, you are already hardcoding the key so it won’t make much difference in the echo itself.

You must be logged in to reply to this support post. Sign In or Register for an Account

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3 Documentation for Event Espresso 4

Status: publish

Updated by  Tony 2 months, 2 weeks ago ago

Topic Tags


This topic is: not resolved
Do NOT follow this link or you will be banned from the site!