Title: PHP loop display week&#039;s events
Last modified: August 22, 2016

---

# PHP loop display week's events

 *  Resolved [ButlerWeb](https://wordpress.org/support/users/butlerweb/)
 * (@butlerweb)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/php-loop-display-weeks-events/)
 * Hey guys! I have intermediate knowledge of php and I’m editing the code for the
   events calendar shortcode.
 * Currently I have this for the meta query:
 *     ```
       $posts = get_posts( array(
       				'post_type' => 'tribe_events',
       				'posts_per_page' => $ecs_limit,
       				'tax_query'=> $ecs_event_tax,
       				'meta_key' => '_EventStartDate',
       				'orderby' => 'meta_value',
       				'order' => $ecs_order,
       				'meta_query' => array(
       									   array(
   
       'key' => '_EventStartDate',
       'value' => date('Y-m-d'),
       'compare' => '>=',
       'type' => 'DATETIME'
   
       )
   
       )
       ) );
       ```
   
 * I know I want events to show up following this pattern:
 * **Week is Sunday-Saturday
    Include all events that start OR end during that week.
 * Any help? 🙂 Thanks!
 * [https://wordpress.org/plugins/the-events-calendar/](https://wordpress.org/plugins/the-events-calendar/)

Viewing 1 replies (of 1 total)

 *  [Brook](https://wordpress.org/support/users/brook-tribe/)
 * (@brook-tribe)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/php-loop-display-weeks-events/#post-5654695)
 * Howdy ButlerWeb,
 * Tribe reps cant help much with customizations, though I hope the community still
   might be able to. But it looks like you are almost there. You just need to make
   sure that the events start date is greater than the end of the week, or less 
   than the start, or if the end date is either of those. Usually this accomplished
   with multiple SQL brackets in the where clause.
 * Cheers!
 * – Brook

Viewing 1 replies (of 1 total)

The topic ‘PHP loop display week's events’ is closed to new replies.

 * ![](https://ps.w.org/the-events-calendar/assets/icon-256x256.gif?rev=2516440)
 * [The Events Calendar](https://wordpress.org/plugins/the-events-calendar/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/the-events-calendar/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/the-events-calendar/)
 * [Active Topics](https://wordpress.org/support/plugin/the-events-calendar/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/the-events-calendar/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/the-events-calendar/reviews/)

## Tags

 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [week](https://wordpress.org/support/topic-tag/week/)

 * 1 reply
 * 2 participants
 * Last reply from: [Brook](https://wordpress.org/support/users/brook-tribe/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/php-loop-display-weeks-events/#post-5654695)
 * Status: resolved