Title: Incorrect sorting
Last modified: August 31, 2016

---

# Incorrect sorting

 *  [Zexler](https://wordpress.org/support/users/zexler/)
 * (@zexler)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/incorrect-sorting-1/)
 * Using this code:
 *     ```
       <?php
       	$the_query = new WP_Query(array(
           'post_status' =>'published',
           'post_type' =>'post',
           'orderby' => 'meta_value_num',
           'meta_key' => '_liked',
           'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1
           ));
   
       	$postslist = get_posts( $args );
       foreach ($postslist as $post) :  setup_postdata($post); ?>
   
       <?php the_title(); ?><br />
       <?=wp_ulike_get_post_likes(get_the_ID()); ?><br />
   
       <?php endforeach; ?>
       <?php wp_reset_postdata() ?>
       ```
   
 * Articls displayed from 0 to x. How to make from x to 0?
    I tried DESC. Don’t 
   work anyway.
 * What could it be?
 * [https://wordpress.org/plugins/wp-ulike/](https://wordpress.org/plugins/wp-ulike/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [Zexler](https://wordpress.org/support/users/zexler/)
 * (@zexler)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/incorrect-sorting-1/#post-6947504)
 * New code. Shows the correct sorting, but in the wrong direction. DESC dont work.
   `
   <?php $args = array( ‘post_status’ =>’published’, ‘post_type’ =>’post’, ‘orderby’
   => ‘meta_value_num’, ‘meta_key’ => ‘_liked’, ‘posts_per_page’ => 10, ); $postslist
   = get_posts( $args ); foreach ($postslist as $post) : setup_postdata($post); ?
   >
 *  <?php the_title(); ?>
    <?=wp_ulike_get_post_likes(get_the_ID()); ?> <?php //
   the_meta(); ?>
 *  <?php endforeach; ?>
    <?php wp_reset_postdata() ?>

Viewing 1 replies (of 1 total)

The topic ‘Incorrect sorting’ is closed to new replies.

 * ![](https://ps.w.org/wp-ulike/assets/icon.svg?rev=2453069)
 * [WP ULike – Like & Dislike Buttons for Engagement and Feedback](https://wordpress.org/plugins/wp-ulike/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-ulike/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-ulike/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-ulike/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-ulike/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-ulike/reviews/)

## Tags

 * [sorting](https://wordpress.org/support/topic-tag/sorting/)

 * 1 reply
 * 1 participant
 * Last reply from: [Zexler](https://wordpress.org/support/users/zexler/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/incorrect-sorting-1/#post-6947504)
 * Status: not resolved