Can you post the code where you use these order by argument so I can assist you better?
Use print_r to output the results of the query. If they change from fetch to fetch but the front page does not change, then the issue is that the query is working but the page has been cached and you’re seeing the same (old)result over and over. If so, the solution is to exclude that page from your cache — the method of doing so depends on the caching plugin(s) you’re using.
Thread Starter
rondos
(@rondos)
Hi! Still I have not resolved this problem. Orderby rand not working. There is my query:
$args = array(
'cat' => 2,
'posts_per_page' => 12,
'orderby' => 'rand'
);
$query = new WP_Query( $args );
I used print_r to check for changes, but result all time same. There is begining of my query print_r result:
WP_Query Object ( [query] => Array ( [cat] => 2 [posts_per_page] => 12 [orderby] => rand ) [query_vars] => Array ( [cat] => 2 [posts_per_page] => 12 [orderby] => meta_value [error] => [m] => [p] => 0
-
This reply was modified 8 years, 11 months ago by
rondos.
See how the query_vars[orderby] became meta_value? Something is hooked into the query process and altering the orderby. I get random posts in a category with your query on my site, so there’s nothing wrong with that.
You may need to do the deactivate all plugins and switch to a default theme process. Restore each extension one at a time until the problem returns. The last activated extension is altering your query.