Title: Support for WP_Query object
Last modified: August 22, 2016

---

# Support for WP_Query object

 *  [jakgra](https://wordpress.org/support/users/jakgra/)
 * (@jakgra)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/support-for-wp_query-object/)
 * Thank you very much for your plugin. It is exactly what I needed. But this plugin
   only works with query_posts and not with WP_Query Object. See here: [https://wordpress.org/support/topic/query-posts-8?replies=5](https://wordpress.org/support/topic/query-posts-8?replies=5).
   
   As I had a shortcode that used WP_Query Object it didn’t work. But for me the
   fix was to change 12 lines of code:
 * Line 61-63 (in function ReOrderPostWithinCategory) from:
 *     ```
       add_filter('posts_join', array(&$this, 'reOrder_query_join'));
       add_filter('posts_where', array(&$this, 'reOrder_query_where'));
       add_filter('posts_orderby', array(&$this, 'reOrder_query_orderby'));
       ```
   
 * to:
 *     ```
       add_filter('posts_join', array(&$this, 'reOrder_query_join'), 10, 2);
       add_filter('posts_where', array(&$this, 'reOrder_query_where'), 10, 2);
       add_filter('posts_orderby', array(&$this, 'reOrder_query_orderby'), 10, 2);
       ```
   
 * Line 67-69 from:
 *     ```
       public function reOrder_query_join($args){
   
          global $wpdb,$wp_query;
       ```
   
 * to:
 *     ```
       public function reOrder_query_join($args, $wp_query){
   
          global $wpdb;
       ```
   
 * Line 91-92 from:
 *     ```
       public function reOrder_query_where($args){
          global $wpdb,$wp_query;
       ```
   
 * to:
 *     ```
       public function reOrder_query_where($args, $wp_query){
          global $wpdb;
       ```
   
 * And line 115-116 from:
 *     ```
       public function reOrder_query_orderby($args){
          global $wpdb,$wp_query;
       ```
   
 * to:
 *     ```
       public function reOrder_query_orderby($args, $wp_query){
          global $wpdb;
       ```
   
 * If it doesn’t break anything I suggest you(the author) include the changes here
   on the WordPress Plugin Directory.
    If you have the same problem and the plugin
   has not been fixed yet just change the mentioned lines (the fix works for plugin
   version 1.1.6), and it should work.
 * [https://wordpress.org/plugins/reorder-post-within-categories/](https://wordpress.org/plugins/reorder-post-within-categories/)

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

 *  [thisislawatts](https://wordpress.org/support/users/thisislawatts/)
 * (@thisislawatts)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/support-for-wp_query-object/#post-5759366)
 * Thanks for this [@jakgra](https://wordpress.org/support/users/jakgra/), that’s
   working brilliantly. For anyone that comes after a copy & pastable patched version
   of 1.1.6:
    [https://gist.github.com/thisislawatts/acedf49b7f40a9f18bfb](https://gist.github.com/thisislawatts/acedf49b7f40a9f18bfb)
 *  [MaxUrbanMedia](https://wordpress.org/support/users/maxurbanmedia/)
 * (@maxurbanmedia)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/support-for-wp_query-object/#post-5759402)
 * Hi guys,
 * I have a multi site and I am using the Reorder posts in categories plugin.
 * Just used this code and it works on the main website but I am having issues on
   the others.
 * Any suggestions would be greatly appreciated.
 * Thanks,
    Max

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

The topic ‘Support for WP_Query object’ 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/)

## Tags

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

 * 2 replies
 * 3 participants
 * Last reply from: [MaxUrbanMedia](https://wordpress.org/support/users/maxurbanmedia/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/support-for-wp_query-object/#post-5759402)
 * Status: not resolved