meta queries do ‘either/or’ checks

meta_query works on ‘both/and’ checks and also ‘either/or’.so don’t worry.your coding was correct.this is the actual format… $a = new WP_Query( array( ‘fields’ => ‘ids’, ‘ignore_sticky_posts’ => true, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘foo’, ‘value’ => array( ‘foobar’ ), ‘compare’ => ‘IN’ ), array( ‘key’ => ‘bar’, ‘value’ => array( ‘foobar2’ … Read more

difference between querying database and using the loop

There is no absolute better/worse/best/worst implementation. The correct implementation depends on what you’re trying to accomplish. For a great explanation, I direct you to this post by Digging Into WordPress, which explains the 4 basic means of interacting with the WordPress Loop: Default Loop So what makes it “default”? Mostly because it uses the default … Read more

How to querry for an item that saved in an array?

Jenny, first of all, I think you may be better off using Taxonomy Parameters in you queries. However, there are a couple of hackish ways to do what you want to some extent. $my_query = new WP_Query( ‘post_type=post&posts_per_page=-1’ ); $posts = $my_query->get_posts(); foreach ( $posts as &$post ) { // Get the details and unset … Read more

Create a list of recent Custom Post Types posts

You can use custom variables ($recentPosts) like this: $recentPosts = new WP_Query(array(‘showposts’ => 9, ‘post_type’ => array(‘mycustomposttype1’, ‘mycustomposttype2′,’mycustomposttype3’))); while( $recentPosts->have_posts() ) : $recentPosts->the_post(); the_title(); endwhile; But if you want to use the loop like normal loop, you need to use $wp_query as the variable. Also, everyone uses the parameters directly to the class as a … Read more

Inefficient Query Confusion

…or try this: // … put your $today and $future variables here… global $wpdb; $events = $wpdb->get_results( ” SELECT * FROM {$wpdb->posts} LEFT JOIN( SELECT DISTINCT post_id, (SELECT CAST(meta_value AS DATE) FROM {$wpdb->postmeta} WHERE {$wpdb->postmeta}.post_id = meta.post_id AND meta_key =’opening_time’) AS opening_time, (SELECT CAST(meta_value AS DATE) FROM {$wpdb->postmeta} WHERE {$wpdb->postmeta}.post_id = meta.post_id AND meta_key =’artist_talk_time’) … Read more