WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Query Events (3 posts)

  1. dadvan
    Member
    Posted 1 year ago #

    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/

  2. angelo
    NetWebLogic Support
    Posted 1 year ago #

  3. dadvan
    Member
    Posted 1 year ago #

    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 ); ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags