Custom loop
-
Hi,
I have this filter on my theme functions.php . As you can see, this loops through posts and displays only posts that have a custom field called calendar_date filled with a date >= today date. So that, we display only upcoming events.
How can we do the same thing with Swift theme ?
function my_events_ie($query) { if (!is_admin() && is_singular() && $query->is_main_query()) { $query->set('posts_per_page', -1); $query->set('no_found_rows', true); $query->set( 'meta_key', 'calendar_date' ); $query->set( 'order', 'ASC'); $query->set( 'meta_query', array( array( 'key' => 'calendar_date', 'compare' => '>=', 'value' => current_time('Y-m-d'), 'type' => 'DATE', ) ) ); } //return $query; } add_filter('pre_get_posts', 'my_events_ie');
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘Custom loop’ is closed to new replies.