Mutlipe Custom fileds order by
-
Hi :
I’m writing a query_post like this .$args = array( 'post_type' => DEBBING_TYPE_SLUG, 'post_status' => 'publish', 'meta_query' => array( array( 'relation' => 'AND', 'status_clause' => array( 'key' => '_debbing_status', // 'type' => 'NUMERIC', ), 'order_clause' => array( 'key' => '_debbing_order', // 'type' => 'NUMERIC', ), ) ), 'orderby' => array( 'status_clause' => 'DESC', 'order_clause' => 'DESC', ) );
query_posts($args);
And use query monitor the sql is below :
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
INNER JOIN wp_postmeta
ON ( wp_posts.ID = wp_postmeta.post_id )
INNER JOIN wp_postmeta AS mt1
ON ( wp_posts.ID = mt1.post_id )
WHERE 1=1
AND ( ( wp_postmeta.meta_key = ‘_debbing_status’
AND mt1.meta_key = ‘_debbing_order’ ) )
AND wp_posts.post_type = ‘debbing’
AND (wp_posts.post_status = ‘publish’
OR wp_posts.post_status = ‘private’)
GROUP BY wp_posts.ID
ORDER BY CAST(wp_postmeta.meta_value AS SIGNED) DESC, CAST(mt1.meta_value AS SIGNED) DESC
LIMIT 0, 10Every time i reload the page ,the result is different .
The page I need help with: [log in to see the link]
- The topic ‘Mutlipe Custom fileds order by’ is closed to new replies.