WP_Query with multiple meta fields filter?

I have the following query but it is still returning results which include posts which have a meta value of ‘deal’. Any Clues on what am i missing in this $args = array( ‘post_type’ => POST_TYPE, ‘meta_key’ => ‘is_hot’, ‘meta_value’ => ‘1’, ‘meta_compare’ => ‘=’, ‘posts_per_page’ => 20, ‘no_found_rows’ => true, ‘suppress_filters’ => false, ‘meta_key’ … Read more

WordPress documentation – WP_Query arguments

I’ve been looking for a list all WP_Query arguments. This looks obvious, but http://codex.wordpress.org/Function_Reference/WP_Query isn’t helpful at all, “post_type” is mentioned only in an example, and arguments like “posts_per_page” aren’t even there. 2 Answers 2 I believe this is what you’re looking for. (You’re right to look for it on the class documentation…i think the … Read more

WordPress WP_Query() Not working properly

We would like to know that how we occur error when we implement this code in our sidebar.php $categories = get_categories(); foreach($categories as $category) { printf(‘<h2>%s</h2><ul>’, $category->cat_name); $posts = new WP_Query(‘cat=”.$category->cat_ID); while($posts->have_posts()) { $posts->the_post(); echo “<li>’, the_title(), ‘</li>’; } print ‘</ul>’; } The error we are getting: Fatal error: Cannot use object of type WP_Query … Read more

Can’t get drafts with WP_Query using post_status parameter

I can’t seem to get drafts to show up with WP_Query, even when post_status is set to ‘any’ or ‘draft’ $args = array( ‘p’ => 1234, ‘post_type’ => ‘any’, ‘post_status’ => ‘any’ ); $query = new WP_Query( $args ); while ( $query->have_posts() ) : $query->the_post(); // display the post endwhile; wp_reset_postdata(); If I go back … Read more

posts_per_page doesnt work

Here is the my custom query ; <?php $Poz = new WP_Query(array( ‘posts_per_page’ => 3, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘no_found_rows’ => true, ‘update_post_term_cache’ => false, ‘update_post_meta_cache’ => false, )); // The Query $the_query = new WP_Query( $Poz ); // The Loop while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <li><a href=”https://wordpress.stackexchange.com/questions/70424/<?php the_permalink(); ?>” title=”<?php … Read more

Use post__in and post__not_in together?

I’m trying to only show posts that a user hasn’t seen, like this: $exclude = array(1,2,3); $include = array(3,4,5); $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 30, ‘post__in’ => $include, ‘post__not_in’ => $exclude, ‘orderby’ => ‘post__in’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => … Read more

Group posts by year in loop

How can I separate posts by year in archive page for Custom Post Type? while ( have_posts() ) : the_post(); the_title(); the_post_thumbnail(‘thumb’); endwhile; The end result would look something like this: 2016 – Title1 – Title2 – Title3 – Title4 2015 – Title1 – Title2 – Title3 – Title4 etc. 1 Answer 1 This little … Read more