Pulling in custom queries to my custom homepage

Home Forums Calendar Products Events Calendar PRO Pulling in custom queries to my custom homepage

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1185430
    Kari Acker
    Participant

    Hi,

    So im using a custom query to pull in some event info. Basically I want to pull in the title, date (September 9th, 2017) and the location. City, State.

    I have the title and the date pulling in, the date is not in the format I want thought, but I cant seem to pull in the city and state. I think it because is pulling that info from a different custom post type?

    Just seeing if anyone out there can lend a hand on my code.

    <div class="small-12 medium-6 large-8 columns">

    Upcoming Events

    View All Events
    <table class="stack events-table">
    <tbody>
    <?php $events = new WP_Query( array('post_type' => Tribe__Events__Main::POSTTYPE,) );
    while ( $events->have_posts()) { $events->the_post(); ?>
    <tr>
    <td>">

    <?php the_title(); ?>

    </td>
    <td>">

    <?php echo get_post_meta($post->ID, '_EventStartDate', true); ?>

    </td>
    <td>

    <?php echo get_post_meta($post->ID, '_VenueCity', true); ?>

    </td>
    </tr>
    <?php wp_reset_postdata(); } ?>
    </tbody>
    </table>
    </div>

    #1185758
    Geoff
    Member

    Hi Kari and welcome to the forums!

    Oh shoot, it looks like the code got a little mangled and it’s a little tough to read. I think I got the gist of it though.

    I would actually recommend using the tribe_get_events() function as an easier means for working with event data and queries. It’s basically a wrapper for the the_post that is tied directly to events.

    Here is a guide that provides a full rundown of how the function works to query events:

    https://theeventscalendar.com/knowledgebase/using-tribe_get_events/

    Once you call the function, you can call other event-specific functions as well to get other pieces of event data.

    For example, where you call the event’s start date like this:

    <?php echo get_post_meta($post->ID, '_EventStartDate', true); ?>

    …you could use this instead:

    <?php echo tribe_get_start_date(); ">

    Similarly, where you call the Venue city like this:

    <?php echo get_post_meta($post->ID, '_VenueCity', true); ?>

    …you could use this instead:

    <?php echo tribe_get_city(); ?>

    That will give you some cleaner, more readable code for sure. For reference, please do check out our documentation for a full list of all the available functions the plugin includes.

    Does this make sense and will it help you get started? Please let me know. 🙂

    Cheers!
    Geoff

    #1196515
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Pulling in custom queries to my custom homepage’ is closed to new replies.