My code is:
$sliders = new WP_Query(array('post_type' => 'sliders', 'showposts' => '10', 'orderby' => 'menu_order', 'order' => 'ASC', 'countries'=> 'Default', 'supress_filters' => true, 'meta_query' => array(
But wordpress orderby post_date 🙁
[query] => Array
(
[post_type] => sliders
[showposts] => 10
[orderby] => menu_order
[order] => ASC
[countries] => ES
[supress_filters] => 1
[meta_query] => Array
(
[0] => Array
(
[key] => _sectors
[value] => 540
[compare] => IN
)
)
)
[request] => SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) JOIN wp_icl_translations t ON wp_posts.ID = t.element_id
AND t.element_type = 'post_sliders' JOIN wp_icl_languages l ON t.language_code=l.code AND l.active=1 WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (16) ) AND wp_posts.post_type = 'sliders' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') AND ( (wp_postmeta.meta_key = '_sectors' AND CAST(wp_postmeta.meta_value AS CHAR) IN ('540')) ) AND t.language_code='es' GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10
Use this instead. It worked for me
First, it’s
suppress_filters
with two P’s.Secondly, ‘countries’ => ‘default’ doesn’t do anything in a normal query, so I suspect you have something else going on code-wise.
Third, when I do your query with this code
I get this result:
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) WHERE 1=1 AND wp_posts.post_type = 'sliders' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'future' OR wp_posts.post_status = 'draft' OR wp_posts.post_status = 'pending' OR wp_posts.post_author = 1 AND wp_posts.post_status = 'private') AND ( (wp_postmeta.meta_key = '_sectors' AND CAST(wp_postmeta.meta_value AS CHAR) IN ('540')) ) GROUP BY wp_posts.ID ORDER BY wp_posts.menu_order ASC LIMIT 0, 10
Notice that the order by menu order is correct.
I think (could be wrong) the problem is only pages have menu_order. Also, when you registered the post_type did you set it to
'hierarchical' => true,
?