I've a problem with my query_posts()
call.
Here is my code:
$results = $wpdb->get_results("SELECT post_id FROM " . $wpdb->postmeta . " WHERE meta_key = 'mashsb_shares' ORDER BY CAST(meta_value AS SIGNED) DESC LIMIT 0, 20");
$top_ideas = array();
foreach($results as $result) {
foreach($result as $key => $value) {
array_push($top_ideas, $value);
}
}
print_r($top_ideas);
query_posts( array( 'post__in' => $top_ideas, 'orderby' => 'post__in' ) );
My problem is that posts doesn't appear in the order of my post__in
array ($top_ideas
).
My print_r()
shows the right array, so my $results
's query works good. The problem is in my query_posts()
call, but I can't find what problem is... I just understood that the query_posts() method is never called. If I take it out, nothing change.
Thanks for your help!
query_posts()
here. wordpress.stackexchange.com/questions/50761/… and developer.wordpress.org/reference/functions/query_posts