• Resolved 000000000

    (@pealo86)


    I am using the following function:

    // get post meta
    function get_meta($key) {
    	$meta = get_post_meta(get_the_ID(), $key, true);
    	if($meta) {
    		return $meta;
    	} else {
    		 return false;
    	}
    }

    To echo meta values of event posts like so:

    <ul class="meta-event">
    	<li><strong>On:</strong> <?php the_field('_EventStartDate'); ?></li>
    	<li class="last"><strong>Price:</strong> £<?php the_field('_EventCost'); ?></li>
    	<li><strong>Location:</strong> <?php the_field('_VenueCity'); ?></li>
    	<li class="last"><a class="more" href="<?php echo get_permalink(); ?>">Find Out More / Enquire ?</a></li>
    </ul>

    However the value for ‘_VenueCity’ returns nothing! Even though I can see it in my database.

    Does anyone know what could be wrong? I really can’t see what the problem is as I echo meta values like this all the time.

    I’ve even tried with the ‘the_field()’ function from ACF but with no joy.

    https://www.ads-software.com/extend/plugins/the-events-calendar/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hey peola86. Thanks for the heads up on this, and sorry to hear you’re having issues. Not sure what’s up here myself but this is troubling – let me get our developer Jonah to take a look and see if this is a bug of some kind, or if there’s anything we can do to point you in the right direction.

    Stay tuned, and apologies for the inconvenience in the interim.

    Thread Starter 000000000

    (@pealo86)

    Great stuff, thanks!

    It seems bizarre though, I can’t really see how it could be related to the plugin when it’s just a value stored in the meta_value field?

    I’m not sure if maybe the preceding ‘_’ character has something to do with it perhaps.

    No idea, myself ?? Hopefully Jonah will have some ideas when he hits the forum, which should be sometime today.

    Hey pealo86,

    I’m not sure why you cannot use the_field() to echo values from our plugin but you’ll have to take that up with Elliot @ ACF because that’s a function of his plugin, not ours. It might only work with ACF created fields and not just any meta.

    With your get_meta() function you should just need to call it like so to echo the start date for example:

    echo get_meta('_EventStartDate');

    … worked for me.

    Let me know if you need any other help with this.

    – Jonah

    Thread Starter 000000000

    (@pealo86)

    Can you get the following to work though?

    <?php echo get_meta('_VenueCity'); ?>

    That’s the problem I’m having, I only tried with ACF because I couldn’t get my get_meta() function to echo the venue field.

    I can get *some* fields to echo with both my function *and* the ACF function. Such as the price field, that echoes fine.

    However it’s just one or two fields that simply aren’t having it (e.g. _VenueCity).

    I think this is because the Venue is actually another post type and is linked to an event in a way that doesn’t make it easily accessible with get_post_meta.

    Fortunately we have an internal function you can call that should pull the data for you:

    echo tribe_get_venue( get_the_ID() );

    – Jonah

    Thread Starter 000000000

    (@pealo86)

    Ahh right I see! Thanks I’ll give that function a try ??

    Funnily enough it did occur to me that perhaps I could use that after I posted this thread, but completely forgot as I haven’t worked on the project in a while!

    Matt.

    No problem pealo86, let us know if you need anything else.

    – Jonah

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: The Events Calendar] Trouble Echoing Certain Meta Values’ is closed to new replies.