WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Reverse sort order of wp_page_menu (4 posts)

  1. schaefermic
    Member
    Posted 5 years ago #

    Im using the wp_page_menu command to display the list of all pages I have on the my site on a template page. The only issue is that when i sort by post_date, it displays the oldest first, instead of the newest page.
    Currently I'm using:

    <?php wp_page_menu( array( 'sort_column' => 'post_date' ) ); ?>

    Is there any to reverse this order? im no php wizard.

  2. schaefermic
    Member
    Posted 5 years ago #

    anyone know if there is a fix for this?

  3. vtxyzzy
    Member
    Posted 5 years ago #

    Even though it is not shown in the Codex, I think you can use this:

    <?php wp_page_menu( array( 'sort_column' => 'post_date', 'sort_order' => 'ASC' ) ); ?>

    The documentation for wp_list_pages, which is called by wp_page_menu, says that 'ASC' is the default, so you might also try 'DESC'. That sounds wrong to me because older dates ought to be smaller but maybe post_date is being recalculated to mean post_age.

  4. schaefermic
    Member
    Posted 5 years ago #

    Ahhh, that'll do it!

    DESC got it to start with the newest.

    Thanks SO much!

Topic Closed

This topic has been closed to new replies.

About this Topic