Using relative date patameters in standard wp_query

WordPress Event Management, Calendars & Registration Forums General Question Using relative date patameters in standard wp_query

This topic contains 2 replies, has 2 voices, and was last updated by  Stephen Harris 11 years, 11 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #3004

    Hi there,

    I’m trying to configure a standard wp_query and use the relative date parameters for wp event organiser. But it’s not working – am I using these incorrectly? I tried using your eo_get_events() function but I struggled to pull in other fields for the event post such as the excerpt.

    Any help appreciated.


    array( 'event' ),
    'event_end_after'=>'now',
    'orderby' => 'menu_order',
    'order' => 'ASC',
    'posts_per_page' => 10,
    'paged' => $paged
    ) ); ?>
    have_posts() ) : $loop->the_post(); ?>

            <div class="post ">
    

    <h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <p class="teaser"><?php the_excerpt_rss(); ?> <a class="morelink" href="<?php the_permalink() ?>" title="<?php the_title(); ?>">[More]</a></p>
    </div>
    <?php endwhile; wp_reset_query(); ?>

    Dan Branigan
    #3005

    Let me try that code paste again!


    array( 'event' ),
    'event_end_after'=>'now',
    'orderby' => 'menu_order',
    'order' => 'ASC',
    'posts_per_page' => 10,
    'paged' => $paged
    ) ); ?>
    have_posts() ) : $loop->the_post(); ?>

    <div class="post ">

    <a href="" title="">
    <a class="morelink" href="" title="">[More]

    Dan Branigan
    #3006

    Hi Dan,

    Looks like the forum swallowed your code… The forum uses markdown and the easiest way to display blocks of code is to leave a blank line and indent the lines of code by at least 4 spaces. Alternatively, write out the code, highlight it and use the {} icon. Back tics can be used for inline-code.

    As for your question, try

     $event_query = new WP_Query( array(
       'post_type' => 'event', //Pass as string rather than array
       'suppress_filters' => false, //Just to be sure it isn't set to 'true'.
       'event_end_after'=>'now',
       'orderby' => 'eventstart', //There isn't a menu order for events
       'order' => 'ASC',
       'posts_per_page' => 10,
       'paged' => $paged
     ) );
    

    When using eo_get_events() – as with get_posts() – you can’t automatically use functions like the_content() and the_exerpt() as these need to be used in side ‘the loop’*. Also, when using other functions provided by Event Organiser outside of loop (e.g. eo_get_the_start()), then you will need to pass the post ID and (where appropriate) the occurrence ID (see examples)

    Hope that helps!


    * (I wrote an article about using the_content() outside of the loop.- by following that you can use eo_get_events() as if you were ‘in the loop’ too)

    Stephen Harris
Viewing 3 posts - 1 through 3 (of 3 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.