Title: OuchMyAppendix's Replies | WordPress.org

---

# OuchMyAppendix

  [  ](https://wordpress.org/support/users/ouchmyappendix/)

 *   [Profile](https://wordpress.org/support/users/ouchmyappendix/)
 *   [Topics Started](https://wordpress.org/support/users/ouchmyappendix/topics/)
 *   [Replies Created](https://wordpress.org/support/users/ouchmyappendix/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/ouchmyappendix/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/ouchmyappendix/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/ouchmyappendix/engagements/)
 *   [Favorites](https://wordpress.org/support/users/ouchmyappendix/favorites/)

 Search replies:

## Forum Replies Created

Viewing 1 replies (of 1 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Post Types Order] [Plugin: Post Types Order] autosort replaces existing order of all post queries](https://wordpress.org/support/topic/plugin-post-types-order-autosort-replaces-existing-order-of-all-post-queries/)
 *  [OuchMyAppendix](https://wordpress.org/support/users/ouchmyappendix/)
 * (@ouchmyappendix)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/plugin-post-types-order-autosort-replaces-existing-order-of-all-post-queries/#post-3067107)
 * [@gavin27](https://wordpress.org/support/users/gavin27/) : Here is the whole 
   function to copy/paste. Original line is commented out and the modification is
   present.
 *     ```
       function CPTOrderPosts($orderBy)
           {
               global $wpdb;
   
               $options = get_option('cpto_options');
   
               if (is_admin())
                       {
                           if ($options['adminsort'] == "1")
                               $orderBy = "{$wpdb->posts}.menu_order, {$wpdb->posts}.post_date DESC";
                       }
                   else
                       {
                           if ($options['autosort'] == "1")
                           	// Here is where the edit goes
                           	$orderBy = "{$wpdb->posts}.menu_order, " . $orderBy;
                               //original code is commented out
                               //$orderBy = "{$wpdb->posts}.menu_order, {$wpdb->posts}.post_date DESC";
                       }
   
               return($orderBy);
           }
       ```
   
 * [@op](https://wordpress.org/support/users/op/) – Thanks so much for this, I was
   having an issue with this plugin changing the order of attachments on my page
   and this fixed it. Kudos!

Viewing 1 replies (of 1 total)