-
-
Save joshfeck/e3c9540cd4ccc734e755 to your computer and use it in GitHub Desktop.
<ul class="events"> | |
<?php | |
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; | |
$atts = array( | |
'paged' => $paged, | |
'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 EventEspresso\core\domain\services\wp_queries\EventListQuery( $atts ); | |
if (have_posts()) : while (have_posts()) : the_post(); | |
?> | |
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> | |
<?php do_action( 'AHEE_event_details_after_the_event_title', $post ); ?> | |
</li> | |
<?php | |
endwhile; | |
$big = 999999999; // need an unlikely integer | |
echo paginate_links( | |
array( | |
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), | |
'format' => '?paged=%#%', | |
'current' => max( 1, get_query_var('paged') ), | |
'total' => $wp_query->max_num_pages | |
) | |
); | |
else: | |
?> | |
<li>No Upcoming Events</li> | |
<?php | |
endif; | |
// now reset the query and postdata | |
wp_reset_query(); | |
wp_reset_postdata(); | |
?> | |
</ul> |
What a wonderful example.
Thanks josh.
May u help me out in further query modification?
Hope you will :)
I want to use meta_query to list events on page.
Somewhat like below code.
$atts = array(
'title' => NULL,
'limit' => 10,
'css_class' => NULL,
'show_expired' => FALSE,
'month' => NULL,
'category_slug' => NULL,
'order_by' => 'start_date',
//'order_by' => 'end_date',
'sort' => 'DESC',
'meta_query' => array(
array(
'key' => 'start_date',
'value' => '2017-01-08 08:00:00',
'type' => 'DATETIME',
'compare' => '>=',
),
)
);
I want to implement search functionality for Event Espresso and i have those fields:
State - Dropdown (How to list all state? May be Venue)
Category - Dropdown
Start Date - Datepicker
End Date - Datepicker
Keyword - input
On submit those values will be submitted and based on those , i will get filtered events that are related with those values.
So how to implement this?
Please help.
Thanks in Advance
@robynlarsen, I tried using
category_slug => 'my-category'
and that worked. I think for multiple categories, you might try something like an arraycategory_slug => array('category1', 'category2')