Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
share|improve this question
    
I doubt this is your problem but both showposts and and {tax} (where you use 'countries') are deprecated. Use posts_per_page and a tax_query instead. –  mrwweb Jun 21 '12 at 14:28
add comment

2 Answers 2

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

$sliders = new WP_Query(array('post_type' => 'sliders', 
'showposts' => '10', 
'orderby' => 'menu_order', 
'order' => 'ASC', 
'countries'=> 'Default', 
'suppress_filters' => true, 
'meta_query' => array( array(
    'key' => '_sectors',
    'value' => 540,
    'compare' => 'IN',
    ) ),
) );

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.

share|improve this answer
add comment

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, ?

share|improve this answer
    
How is this relevant to the question? Please post an explanation –  Pieter Goosen May 22 at 10:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.