Support » Plugin: Church Community Builder Core API » Event Date, Image & Location

  • Resolved jeremysmcknight

    (@jeremysmcknight)


    Hey everyone I’ve just started using this wonderful plugin, Jared I really appreciate everything you are doing. As someone that knows nothing about API you’ve made it doable 🙂 I am having an issue with Events. I was curious if there is a way to add event images to featured images like the group settings offer. https://ibb.co/gWPyfx Here is an image of the dashboard of the events I don’t see the date/time or location is that information that cannot be provided. I would love to add the date through syncing instead of editing each event wordpress page.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jared Cobb

    (@jaredcobb)

    Hi Jeremy,

    I’m glad the plugin is helpful.

    So for additional data (like the dates, times, and locations), the plugin is storing it as post meta (aka custom fields). Here’s a little more info on post meta: https://codex.wordpress.org/Custom_Fields.

    So in order to fetch the data, it’s best to use a function called get_post_meta() like so:

    $location = get_post_meta( get_the_ID(), 'location', true );
    
    if ( ! empty( $location ) {
    	echo '<strong>Location:</strong> ' . $location;
    }

    … This code would run inside your loop from your previous example where you made a custom query like so: $related_items = new WP_Query( $args );

    While you’re coding, I recommend using this plugin: https://wordpress.org/plugins/post-meta-inspector/. It’s a nice way to inspect the post meta on a post (from within the WordPress post edit page) and makes it easier to see what post meta is available to you, and their keys / values.

    Dates, Start Times, and End Times are also stored as post meta. This is because if you were to change the actual WordPress post date to the future, WordPress would assume you wanted to wait to display that event “post” until that future date (and they won’t show up).

    As for event images, yes. There’s actually a snippet / recipe I recently added to the Wiki here: https://github.com/jaredcobb/ccb-core/wiki/Download-&-Attach-Event-Images. The idea is that you should be able to copy / paste that into your theme’s functions.php without any problems. Of course, you’re free to organize the code in your theme any way you see fit (maybe create a dedicated ccb-core.php file and include that file from within functions.php if you want to keep it separate).

    Great that helps so much I’ve got the date to show up as 2018-02-25. using this code

    <?php
    echo get_post_meta($post->ID, "date", true);
     ?>

    is there any way to make it in the date format ‘F js’ which would be February 25th?

    Plugin Author Jared Cobb

    (@jaredcobb)

    You should be able to use the date() function http://php.net/manual/en/function.date.php. Perhaps something like:

    echo date( 'F js', strtotime( get_post_meta($post->ID, 'date', true) ) );

    Perfect!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Event Date, Image & Location’ is closed to new replies.