1
我想訂購工作在wp_query,但帖子仍然被默認設置(只是tag__in工作)。上崗SQL查詢看起來是這樣的:WordPress的wp_query orderby不工作
string(379) "SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND (wp_term_relationships.term_taxonomy_id IN (81)) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 3"
下面是代碼片段:
remove_all_filters('posts_orderby');
$tag = get_term_by('name', 'title_post', 'post_tag');
$args=array(
'order'=>'ID',
'orderby'=>'ASC',
'tag__in' => $tag,
'posts_per_page'=>3, // Number of related posts to display.
'caller_get_posts'=>1
);
$my_query = new wp_query($args);
var_dump($my_query->request);
謝謝!