• Resolved susanwrotethis

    (@susanwrotethis)


    I’m developing for a blog with an edge case where one of the categories needs to order posts by menu_order (descending) instead of date on the category archive page. The front end is fine. For the back end, I enabled ‘page-attributes’ in the ‘supports’ attribute for posts, and the Post Attributes meta box is appearing as expected in the back end.

    However, when I change the value of the Order field to a non-zero number, the value resets to 0 when I update the post. I’ve taken the usual troubleshooting steps (changed the theme, deactivated all plugins except the one function turning on this meta box, clearing the cache). I think this is a bug that needs to be reported in Trac, but I want to make sure I’m not missing something. Do I need to enable something else that I’m missing?

    We’re on WP 6.5.2 and using Gutenberg.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter susanwrotethis

    (@susanwrotethis)

    Answer found after a deep dive. Trac ticket opened five years ago (https://core.trac.www.ads-software.com/ticket/46264) and it has never been resolved. Sigh.

    Moderator bcworkz

    (@bcworkz)

    You could use the ‘rest_api_init’ hook suggested in the Trac ticket to cause non-zero values to be saved. However, menu_order was never intended for posts or pages, it’s meant for nav menu items. To avoid unintentional use that could break in the future, you’re likely better off saving post order data as a custom field or meta data and ordering posts using the 'orderby'=>'meta_value_num', arg of WP_Query.

    Thread Starter susanwrotethis

    (@susanwrotethis)

    Thanks, I already implemented the patch. Going to trust to menu_order for now. Seeing as that field has been in the page-attributes meta box for pages for as long as I can remember, I can’t imagine it being deprecated without notice.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Setting Menu Order Issue for Posts’ is closed to new replies.