Paging + WP Query

pre_get_posts did the trick (thanks Pieter and cybmeta! Here’s the solution: function hwl_home_pagesize( $query ) { if ( is_post_type_archive( ‘motivation’ ) ) { $query->set( ‘posts_per_page’, 9 ); return; } if ( is_post_type_archive( ‘blog’ ) ) { $query->set( ‘posts_per_page’, 14 ); return; } } add_action( ‘pre_get_posts’, ‘hwl_home_pagesize’, 1 ); That’s it!

Ordering posts by custom field and grouped by month

<?php $period = date(“Y-m-d”); $args = array( ‘post_type’=>’event’, ‘posts_per_page’=> -1, ‘order’=> ‘DESC’, ‘orderby’=> ‘meta_value’, ‘meta_key’=>’event_start_date’ ‘meta_value’ => $period, ) $events = new WP_Query( $args ); if ($events->have_posts()) : while (have_posts()) : the_post(); the_title(); // (etc.) endwhile; endif; ?> Please follow below link for details. Link for details link for code source Thanks!

date_query is showing duplicate results

As I said in comments, you can do this in one query by making use of the relative time and date functionality in PHP which is also vailable in a date_query. You simply need to pass something like 2 days ago to the after parameter in the date_query to get posts from today, yesterday and … Read more

Error in meta_query not get result

Your query seems to be fine and it should work. It’s not returning result probably because you are missing type parameter for ads_status field. So your code should be. <?php $args = array( ‘post_type’ => ‘banner’, ‘posts_per_page’ => 25, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘ads_status’, ‘value’ => ‘1’, ‘type’ => ‘NUMERIC’, … Read more

Group posts by attachment meta key

This is really more of a php/html question as this problem comes up outside of WordPress. What you want to do is check the current meta name against the previous one, and if it’s different, then you echo the header. You’re already pulling all the posts you need in one go, so it’s something like: … Read more