WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] WP_Query and scope of events (4 posts)

  1. afreyer
    Member
    Posted 10 months ago #

    hi,

    i want to list next events with wp_query in my template ordered by a custom field.

    <?php 
    
    $args = array(
    	'post_type' => 'event',
    	'posts_per_page' => 10,
    'orderby' => 'meta_value_num',
    		'order' => 'ASC',
    		'meta_key' => '_start_ts',
    		'meta_value' => current_time('timestamp'),
    		'meta_value_num' => current_time('timestamp'),
    		'meta_compare' => '>=',
    
    	'meta_query' => array(
    		array(
    			'key' => 'color',
    			'value' => 'yellow',
    			'compare' => 'LIKE'
    		)
    	)
    );
    
    // the query
    $the_query = new WP_Query( $args ); ?>
    
    <?php if ( $the_query->have_posts() ) : ?>
    
      <!-- pagination here -->
    
      <!-- the loop -->
      <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    <?php the_title( '<p><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></p>' ); ?>
      <?php endwhile; ?>
      <!-- end of the loop -->
    
      <!-- pagination here -->
    
      <?php wp_reset_postdata(); ?>
    
    <?php else:  ?>
      <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
    <?php endif; ?>

    My Question: How could i manage this, if i want to show only events for the current week. does exist a scope parameter?

    http://wordpress.org/plugins/events-manager/

  2. angelo
    NetWebLogic Support
    Posted 9 months ago #

    have you tried to change 'meta_compare' => '>=', to 'meta_compare' => '>', ?

  3. afreyer
    Member
    Posted 9 months ago #

    no i think you misunderstood my question.this query works fine for me, but i need a solution to list events of the current week or for the next 7 days, like "scope" parameter of eventlist.

  4. caimin_nwl
    NetWebLogic Support
    Posted 9 months ago #

    Take a look at the BETWEEN statements here:

    http://codex.wordpress.org/Class_Reference/WP_Meta_Query

Reply

You must log in to post.

About this Plugin

About this Topic