Title: [Plugin: Post Types Order] Automatic mode does not work
Last modified: August 20, 2016

---

# [Plugin: Post Types Order] Automatic mode does not work

 *  Resolved [pavelevap](https://wordpress.org/support/users/pavelevap/)
 * (@pavelevap)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-post-types-order-automatic-mode-does-not-work/)
 * Hi,
 * using your plugin (premium version), but automatic mode does not work for me.
   I deactivated all plugins and using Twenty Eleven on my testing site. In admin
   I can see that posts are sorted correctly (also in posts list they are sorted
   the right way), but on front end on my category archive, they are not sorted.
   I also checked database and it looks like there are all valid values for menu_order.
   Any idea how it can be caused or how to debug it?
 * Thank you very much for your help…
 * [http://wordpress.org/extend/plugins/post-types-order/](http://wordpress.org/extend/plugins/post-types-order/)

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

 *  Plugin Author [nsp-code](https://wordpress.org/support/users/nsp-code/)
 * (@nsp-code)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-post-types-order-automatic-mode-does-not-work/#post-2452640)
 * Hi,
    This should work, please make sure you turn the Autosort to ON within the
   settings page. If this didn’t do the fix, please contact us directly.
 *  Thread Starter [pavelevap](https://wordpress.org/support/users/pavelevap/)
 * (@pavelevap)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-post-types-order-automatic-mode-does-not-work/#post-2452650)
 * So, I tried to play with it and probably found a bug:
 * 1) After activating plugin, options autosort, adminsort and level are created
   by default with function CPTO_activated().
 * But on Options page, there is following part of condition:
 * `if (!isset($options['allow_post_types']) || ...`
 * And this is always true, because allow_post_types is not defined after activation.
   So user can see that all post types checkboxes are checked by default (even if
   they are really not).
 * It leads to following error:
 * Notice: Undefined index: allow_post_types in plugins/advanced-post-types-order/
   advanced-post-types-order.php
 * And this error is related to this check:
 * `... && !in_array($query->query_vars['post_type'], $options['allow_post_types'])`
 * So, this is always true because $options[‘allow_post_types’] does not exist and
   fires mentioned Notice.
 * 2) And that is why automatic sorting works in this case. But when you have option
   allow_post_types defined then automatic sorting really does not work. And the
   problem will be probably hidden in checking $query->query_vars[‘post_type’] because
   by default it is empty string for example on category archive pages. And plugin
   conditions does not work with it, because empty string is not in array of allow_post_types
   options, so as a result everything ends with returning default $orderBy variable.
 * Maybe related: [http://core.trac.wordpress.org/ticket/19471](http://core.trac.wordpress.org/ticket/19471)
 *  Plugin Author [nsp-code](https://wordpress.org/support/users/nsp-code/)
 * (@nsp-code)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-post-types-order-automatic-mode-does-not-work/#post-2452795)
 * 1) Yes, this is true, but the reason behind this is to make sure all post types
   are passed through by default, unless the user save another settings.
    I am not
   sure how you get the notice as it first check if the option actually exists **
   isset($options[‘allow_post_types’])** so it shouldn’t reach that code you indicated.
   However we changed a lite this code, might fixed that php notice.
 * 2) Indeed in certain cases the **$query->query_vars[‘post_type’]** can be empty(
   so this query var is set) in that case it will return the default order. This
   is fixed in the last version.
 * The last plugin version which include these updates is not yet published as we
   still work to include further improvements, but you can get it using the link
   you got when you made the purchase.
 *  Thread Starter [pavelevap](https://wordpress.org/support/users/pavelevap/)
 * (@pavelevap)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-post-types-order-automatic-mode-does-not-work/#post-2452828)
 * Hi, thank you for your answer!
 * Ad 1) Yes, there is isset check, but in one condition:
 * `if (isset($options['allow_post_types']) && isset($query->query_vars['post_type'])&&!
   in_array($query->query_vars['post_type'], $options['allow_post_types']))`
 * So, all conditions have to be checked by PHP, I guess… It should be avoided with
   two separate conditions – first checking isset and second if statement would 
   check then in_array().
 * Ad 2) I will test new version and let you know…
 *  Thread Starter [pavelevap](https://wordpress.org/support/users/pavelevap/)
 * (@pavelevap)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-post-types-order-automatic-mode-does-not-work/#post-2452833)
 * Version 2.4.0.6 (premium) works well. Thank you for your help!

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

The topic ‘[Plugin: Post Types Order] Automatic mode does not work’ is closed to
new replies.

 * ![](https://ps.w.org/post-types-order/assets/icon-128x128.png?rev=1226428)
 * [Post Types Order](https://wordpress.org/plugins/post-types-order/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/post-types-order/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/post-types-order/)
 * [Active Topics](https://wordpress.org/support/plugin/post-types-order/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/post-types-order/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/post-types-order/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [pavelevap](https://wordpress.org/support/users/pavelevap/)
 * Last activity: [14 years, 5 months ago](https://wordpress.org/support/topic/plugin-post-types-order-automatic-mode-does-not-work/#post-2452833)
 * Status: resolved