• Resolved Doobeedoo

    (@doobeedoo)


    Hello,

    Rank Math HTML sitemap can be ordered by Published date, Modified date, Alphabetical, and Post ID.

    However, the most important is missing: order by Menu Order.

    Most WordPress websites will find a way to re-order their pages, and would like to show pages sorted by Menu Order.

    Is this something you could consider to add, or should I look elsewhere?

    Or could you give code snippet to do this?

    Best regards

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @doobeedoo,

    Thank you for contacting Rank Math support.

    The sort option we currently have can be applied to websites generally.

    Since not all website has the menu you’re referring to, we don’t have the option to sort the HTML sitemap by that order.

    However, you can use and customize this filter to sort the HTML sitemap via your menu order:
    https://rankmath.com/kb/filters-hooks-api-developer/#change-html-sitemap-sort-order

    You can also share the HTML sitemap URL so we can check your menu and suggest the filter to achieve that.

    Looking forward to helping you.

    Thread Starter Doobeedoo

    (@doobeedoo)

    Hello,

    Thank you for your answer

    Menu order is a WordPress core feature, it’s not something specific to my site

    Another of your user has the same issue here:

    The default WordPress pages have an ordered field under page attributes. I would like to order the pages within the HTML sitemap using this order value.

    https://support.rankmath.com/ticket/html-sitemaps-2/

    It would be nice if RankMath would take into account this WordPress core “sort by” field for the HTML sitemap

    My website is on localWP, so I cannot send you the URL, but it’s pretty straightforward: order HTML sitemap by menu order

    In the code you provided:

    add_filter('rank_math/sitemap/html_sitemap/sort_items', function ($sort, $type, $name) {
    return $sort;
    }, 10, 3);

    What should I change to be able to sort the HTML sitemap by Menu order?

    Thanks in advance for your help

    Kind regards

    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello,

    Thank you for your suggestion we have logged it to our Internal to-do lists.

    For now, please change the order by adding the following filter code to your theme’s functions.php file:
    add_filter('rank_math/sitemap/html_sitemap/sort_items', function ($sort, $object_type, $post_type) { if ( $post_type === 'page' ) { // Add here the post_types you want to change the sorting. $sort['field'] = 'menu_order'; $sort['order'] = 'ASC'; } return $sort; }, 10, 3);
    Hope that helps.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Rank Math HTML site map order by Menu order’ is closed to new replies.