How to display posts month by month?

How could wp-query be used to show posts month by month, and have it only show the past year? Or is it possible some wp_archive hack could handle this? 3 Answers 3 WordPress 3.7 introduced the date_query to display posts month by month: $args = array( ‘date_query’ => array( array( ‘month’ => $month ) ) … Read more

get_query_var returns null

My pretty permalink clearly shows the query_var: localhost/site/?tree=312 Yet when I run var_dump(get_query_var(‘tree’)); I get NULL returned. Any reason why? Also when I print_r($wp_query), I can’t find ‘tree’ anywhere. 1 Answer 1 You have to add any query vars that are not WordPress objects to the array of recognized query vars to be able to … Read more

Why is the first query affecting the second query, even after wp_reset_query() and wp_reset_postdata(), but not on the second page?

I am literally clueless as to why the code does not function properly on the first page, but functions as expected on the second page. The second query should return the latest 3 posts in the pagination loop, yet it also returns posts from the first query. Instead of 3 posts on the homepage, there … Read more

Single page theme

I am trying to create single page theme. What i have trouble with is understanding this whole wordpress query logic. There is query object and supposedly i get all published posts like this: $query = new WP_Query( array ( ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘post_type’ => array( ‘page’ ), ‘post_status’ => array( ‘publish’ ) … Read more

Show one post per author and limit query to 8 posts

I want to show 8 recent products from multiple authors on the frontpage. Need to show 1 recent product per author. Currently i’m using basic wp query to show recent 8 products. $args = array ( ‘post_type’ => array( ‘product’ ), ‘posts_per_page’ => ‘8’, ‘order’ => ‘DESC’, ‘orderby’ => ‘date’, ); // The Query $query … Read more

Post queries by latitude and longitude

I am struggling with getting post queries by coordinates. I have meta fields map_lat and map_lng for almost all post types. I am trying to return posts from one custom post type (“beaches” in this example): function get_nearby_locations($lat, $long, $distance){ global $wpdb; $nearbyLocations = $wpdb->get_results( “SELECT DISTINCT map_lat.post_id, map_lat.meta_key, map_lat.meta_value as locLat, map_lng.meta_value as locLong, … Read more

Search Custom Post with meta_value NULL

I need to get only the custom posts which have meta_key landing_exported as meta_value NULL. I know that exists at least 2 custom posts in my database, but my code print “nothing found”. $args = array( ‘post_type’ => LANDING__CUSTOM_POST, ‘meta_query’ => array( array( ‘key’ => ‘landing_exported’, ‘value’ => false, ‘type’ => ‘BOOLEAN’ ) ) ); … Read more