Support

Home Forums Event Espresso Premium exclude some event in global wp_query

exclude some event in global wp_query

Posted: October 23, 2014 at 5:01 am


Ferdie Santiago

October 23, 2014 at 5:01 am

Hi again guys,

Its me again ferdie :), id like to ask what parameter should i add on the attributes line in order to exclude some events not to be listed.
array(
‘title’ => NULL,
‘limit’ => 100,
‘css_class’ => NULL,
‘show_expired’ => FALSE,
‘month’ => NULL,
‘category_slug’ => NULL,
‘order_by’ => ‘start_date’,
‘sort’ => ‘ASC’
);

do i just need to add ‘exclude’=> event_id?

i am using this query below for the event list.

<ul class=”events”>
<?php
$atts = array(
‘title’ => NULL,
‘limit’ => 100,
‘css_class’ => NULL,
‘show_expired’ => FALSE,
‘month’ => NULL,
‘category_slug’ => NULL,
‘order_by’ => ‘start_date’,
‘sort’ => ‘ASC’
);
// run the query
global $wp_query;
$wp_query = new EE_Event_List_Query( $atts );
if (have_posts()) : while (have_posts()) : the_post();
?>

  • “><?php the_title(); ?>
    <?php do_action( ‘AHEE_event_details_after_the_event_title’, $post ); ?>
  • <?php
    endwhile;
    else:
    ?>

  • No Upcoming Events
  • <?php
    endif;
    // now reset the query and postdata
    wp_reset_query();
    wp_reset_postdata();
    ?>


    Dean

    October 23, 2014 at 5:12 am

    Hi,

    I don’t believe there is an exclude variable like that.

    What you could do is add an if statement into the while statement, e.g.

    if (have_posts()) : while (have_posts()) : the_post();
    
    if( get_the_id() == '56') { continue; } //skips this event.
    

    where 56 is the event ID. You could easily swap it to in_array() if you have multiple events that need excluding.


    Ferdie Santiago

    October 23, 2014 at 5:28 am

    Hello Dean,

    Thank you for the info 🙂 It’s case closed!

    Very Impressive Event Espresso Support Staff.
    Thanks again.

    The support post ‘exclude some event in global wp_query’ is closed to new replies.

    Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

    Event Espresso