Title: Query Events
Last modified: August 21, 2016

---

# Query Events

 *  Resolved [dadvan](https://wordpress.org/support/users/dadvan/)
 * (@dadvan)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/query-events/)
 * I would like to pull the events in with a custom query.
    Here is my code but 
   I am not successful getting this to work properly:
 *     ```
       <?php
       						global $post;
       						$querywe_args = array(
       						    'posts_per_page' => 2, // change this to any number or '0' for all
       						    'post_type' => 'event',
       							'tax_query' => array(
       						        array(
       						            'taxonomy' => 'post_tag',
       						            'field' => 'slug',
       						            'terms' => $post->post_name // this gets the page slug
       						        )
       						    )
       						);
       						// a new instance of the WP_query class
       						$querywe = new WP_Query( $querywe_args ); ?>
       ```
   
 * It is querying posts that are a post type of event that has a tag that matches
   the current page’s page slug. This works fine for my regular posts.
 * [http://wordpress.org/extend/plugins/events-manager/](http://wordpress.org/extend/plugins/events-manager/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/query-events/#post-3830715)
 * maybe this can help you out – [http://wordpress.org/support/topic/em-with-wp_query-and-orderby-date?replies=14](http://wordpress.org/support/topic/em-with-wp_query-and-orderby-date?replies=14)
 *  Thread Starter [dadvan](https://wordpress.org/support/users/dadvan/)
 * (@dadvan)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/query-events/#post-3830721)
 * Ended up figuring it out:
 *     ```
       <?php
       						global $post;
       						$querywe_args = array(
       						    'posts_per_page' => 2, // change this to any number or '0' for all
       						    'post_type' => 'event',
       							'tax_query' => array(
       						        array(
       						            'taxonomy' => 'event-tags',
       						            'field' => 'slug',
       						            'terms' => $post->post_name // this gets the page slug
       						        )
       						    )
       						);
       						// a new instance of the WP_query class
       						$querywe = new WP_Query( $querywe_args ); ?>
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Query Events’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=1039078)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

## Tags

 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * 2 replies
 * 2 participants
 * Last reply from: [dadvan](https://wordpress.org/support/users/dadvan/)
 * Last activity: [12 years, 10 months ago](https://wordpress.org/support/topic/query-events/#post-3830721)
 * Status: resolved