Title: Problem using reverse order filter
Last modified: September 24, 2019

---

# Problem using reverse order filter

 *  Resolved [jtbayly](https://wordpress.org/support/users/jtbayly/)
 * (@jtbayly)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/problem-using-reverse-order-filter/)
 * I’m attempting to set several categories to display posts in reverse chronological
   order. (A simple per-category setting to make the default sort order one of the
   three filter options you’ve got would be great, by the way.)
 * Anyway, below is the code for my first attempt. I know the category ID is correct,
   but nothing is happening either on the sorting page or when viewing the category
   page.
 *     ```
       add_filter('reorder_posts_within_category_initial_order', 'reverse_order', 10, 3); 
       function reverse_order($reverse, $post_type, $term_id){
         $reverse = true;
         $post_type = "post";
         $term_id = 184;
         return true;
       }
       ```
   
 * Could you please let me know what’s wrong with the code, and also clarify where
   I should see the difference (sorting page, frontend, or both), and whether I 
   need to turn on manual sorting for the category as well as using this filter?
 * I’ve tried a bunch of things with this filter and not gotten it to work, but 
   I’m not confident enough I understand it to say this is a bug.
 * I appreciate your help.
 * P.S. I’m running the version that just came out this morning. (2.0.1, I think?)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/problem-using-reverse-order-filter/#post-11966158)
 * Your understanding and usage of filters is erroneous. I would suggest that you
   either take a course in WordPress/PHP development or you hire a developer to 
   understand how filters work. I cannot help you with WP core functionality in 
   this forum.
 *     ```
       add_filter('reorder_posts_within_category_initial_order', 'reverse_order', 10, 3); 
       function reverse_order($reverse, $post_type, $term_id){
         //you can only filter the first attribute passed to a filter callback function.
         //the other attributes are there to help you make the right choice.
         if('post' == $post_type && '184' == $term_id) $reverse = true; 
         return $reverse;
       }
       ```
   
 * This plugin **only** lets you order posts manually. The filter you are trying
   to use is for the intially order you see on your admin reorder page. It is a 
   tool to help you sort your posts manually.
 * If what you seek is simpy to reverse the chronological order of your posts in
   the front-end of your site, then you do not need this plugin, you can achieve
   this very easily with the default funtionality already provided in the WP framework
   such as a custom [query](https://developer.wordpress.org/reference/classes/wp_query/).
 *  Thread Starter [jtbayly](https://wordpress.org/support/users/jtbayly/)
 * (@jtbayly)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/problem-using-reverse-order-filter/#post-11972849)
 * Thank you for your help.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Problem using reverse order filter’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/reorder-post-within-categories_c18d38.
   svg)
 * [ReOrder Posts within Categories](https://wordpress.org/plugins/reorder-post-within-categories/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/reorder-post-within-categories/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/reorder-post-within-categories/)
 * [Active Topics](https://wordpress.org/support/plugin/reorder-post-within-categories/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/reorder-post-within-categories/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/reorder-post-within-categories/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [jtbayly](https://wordpress.org/support/users/jtbayly/)
 * Last activity: [6 years, 8 months ago](https://wordpress.org/support/topic/problem-using-reverse-order-filter/#post-11972849)
 * Status: resolved