WP_Query with multiple meta fields filter?

You can not query for multiple meta fields using meta_key and meta_value parameters, you have to use meta_query parameter. Using multiple meta_key and meta_value parameters will use only the first found pair, that is why in your code the condition about “offer_type NOT LIKE deal” is ignored. So, the correct query should be: $args = … Read more

WordPress WP_Query() Not working properly

a possible conflict with the name $posts which is used by wp core; try, for instance: $categories = get_categories(); foreach($categories as $category) { printf(‘<h2>%s</h2><ul>’, $category->cat_name); $cat_posts = new WP_Query(‘cat=”.$category->cat_ID); while($cat_posts->have_posts()) { $cat_posts->the_post(); echo “<li>’, the_title(), ‘</li>’; } print ‘</ul>’; }

Can’t get drafts with WP_Query using post_status parameter

Try passing it as an array. For example $args = array( ‘p’ => 1234, ‘post_type’ => ‘any’, ‘post_status’ => array(‘draft’) ); Or for all types $args = array( ‘p’ => 1234, ‘post_type’ => ‘any’, ‘post_status’ => array(‘publish’, ‘pending’, ‘draft’, ‘auto-draft’, ‘future’, ‘private’, ‘inherit’, ‘trash’) );

posts_per_page doesnt work

Yeah, use ‘nopaging’ => true http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters $Poz = array( ‘posts_per_page’ => 3, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘update_post_term_cache’ => false, ‘update_post_meta_cache’ => false, ‘nopaging’ => true, ); $the_query = new WP_Query( $Poz );

Group posts by year in loop

This little snippet could help you. $years = array(); if( have_posts() ) { while( have_posts() ) { the_post(); $year = get_the_date( ‘Y’ ); if ( ! isset( $years[ $year ] ) ) $years[ $year ] = array(); $years[ $year ][] = array( ‘title’ => get_the_title(), ‘permalink’ => get_the_permalink() ); } } This code gets all … Read more

Get List of all the Authors

You can display author’s list by using function wp_list_authors for more info : http://codex.wordpress.org/Function_Reference/wp_list_authors And for author Template Hierarchy see below link http://codex.wordpress.org/Author_Templates