• I am struggling to do something that I can’t seem to get bend the wp_list_pages or get_pages functions to accommodate. Hopefully someone here can help.

    I have a menu list which appears in several places and is styled in several different ways across the website. I’ve been using a combination of wp_list_pages to either display the primary pages, or their children, depending on where in the page hierarchy the visitor is at using a combination of WordPress’s page slugs and a $_SERVER[‘REQUEST_URI’] variable and it’s working rather nicely.

    But for one of the iterations of this menu, I want to change the order of the list items depending on what the page slug hands off to the URI request.

    So if I’m on a page that is a child of branch 2 of the site’s menu I want that branch’s logo to appear first in the list. It should be a simple reordering of the array, but I’m having trouble making sense of where to start.

    I know get_pages returns values in an array, but the codex document for get_pages() is not too verbose on ways to manipulate that array once it’s been called. Neither function seems to offer a way to manually specify page ordering, and using the include argument to specify the pages doesn’t respect the order in which I list them.

  • The topic ‘Dynamic page ordering with wp_list_pages() or get_pages()’ is closed to new replies.