WP_QUERY orderby not working with posts
-
I’m trying to make a simple Wp_Query() where I get 3 latests posts on my blog.
Easy:
// WP_Query arguments $args = array( 'post_type' => 'post', 'posts_per_page' => 3, 'orderby' => 'publish_date', 'order' => 'DESC', 'post_status' => 'publish', ); // The Query $post_query = new WP_Query($args); if ( $post_query->have_posts() ) { and here goes the loop }But it’s not working for me:
I’ve already tried sorting with:
$args = array( 'post_type' => 'page', 'order' => 'rand', );and also by date, by ID, and the query works perfect. But when I try to order ‘post’ type, it won’t work.
I’ve also tried to show the query (var_dump) and it’s also working as intended. But when it comes to load the page post order won’t change no matter what.
To sum up, I can get pages ordered whichever way I want but I cannot do it with posts using the same code.
¿Any idea of what else can I try?
Thx
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘WP_QUERY orderby not working with posts’ is closed to new replies.