• Resolved pavelevap

    (@pavelevap)


    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…

    https://www.ads-software.com/extend/plugins/post-types-order/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author nsp-code

    (@nsp-code)

    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

    (@pavelevap)

    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: https://core.trac.www.ads-software.com/ticket/19471

    Plugin Author nsp-code

    (@nsp-code)

    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

    (@pavelevap)

    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

    (@pavelevap)

    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.