2

I have a query that displays post the order of the post 1 to 10 and front-end added: <?php print intval( $post->menu_order );?>º there shows 1º, 2º, 3º ... 10º

must reverse the display but keep the number of order to stay well 10º, 9º ... 1º

The post number 1, will remain the 1º but should appear at the end. I do not know how to do this work :(

and not work for me with 'orderby = > 'DESC'

Any idea?

my code:

<?php query_posts(array('post_type'=>'ranking')); ?>
            <?php $mypost = array( 
                'post_type' => 'ranking',
                'orderby' => 'post',                                     
                'posts_per_page' => 10,
                'meta_key'    => 'top10',
                'meta_value'    => 'sim'
                     );
            $loop = new WP_Query( $mypost ); ?>
            <!-- Cycle through all posts -->
            <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
             content format one...       

and it continues on the same page 11 to 50 whith:

 <?php query_posts(array('post_type'=>'ranking')); ?>
            <?php $mypost = array( 
                'post_type' => 'ranking', 
                'orderby' => 'post',                  
                'showposts' => -1 ,
                'meta_key'    => 'top10',
                'meta_value'    => 'nao'               
                 );

            $loop = new WP_Query( $mypost ); ?>
            <!-- Cycle through all posts -->
            <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> 
            content format two...
1
  • You should never use query_posts, use either WP_Query, or if you're modifying the main loop, use the pre_get_posts filter
    – Tom J Nowell
    Jan 5, 2015 at 18:49

1 Answer 1

2

post is not a valid value for orderby parameter neither DESC. You can choose any of these values. Also, you should stop using query_post.

<?php
$args = array( 
            'post_type'      => 'ranking',
            'orderby'        => 'menu_order', 
            'order'          => 'DESC',                                    
            'posts_per_page' => 10,
            'meta_key'       => 'top10',
            'meta_value'     => 'sim'
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) {
     $loop->the_post();
     //Do whatever you want with the posts
}
//After the loop reset post data
wp_reset_postdata();
?>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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