Divide WP_Query posts by date & post type

The post_type isn’t really a meta query – therefore, both of these post_types would at least 1 category added/queried in order to get the filter invoked – using plain SQL is still a last resort. add_filter( ‘posts_groupby’, ‘my_posts_groupby’ ); function my_posts_groupby($groupby) { global $wpdb; $groupby = “{$wpdb->posts}.post_date”; return $groupby; } According to your example (I’d … Read more

How to organise post by category and date

Looking for the solution, I want to give more information about what I have done so far: My Actual configuration – WordPress : 3.8 – PHP : 5.3 – Theme : custom based on _s (underscore) – Hebergeur : local XAMPP My archive template <main id=”main” class=”site-main” role=”main”> <?php // get all the categories from … Read more

Show previous month’s posts

This could be a simple PHP issue of how you are asking to return the first date() date(‘M’, mktime(0, 0, 0, date(‘m’), 0, date(‘Y’))); is returning Dec, and WP_Query needs the month number. First, try changing ‘M’ to ‘m’. date(‘m’, mktime(0, 0, 0, date(‘m’), 0, date(‘Y’))); If that doesn’t work, try using the date_query and … Read more