• Resolved andrewkhunn

    (@andrewkhunn)


    We have quite a few pages on our WordPress install and I find that it makes it quite a bit easier to manage them if they are sorted by name instead of ID. Pre-2.1, all that was needed was an edit to the page_rows() function in admin-functions.php to make the SQL query ORDER BY post_title. In 2.1 however, I see that they have actually implemented a function to call pages (instead of using a SQL query) and even when I change sort_column to post_name, it still isn’t sorting correctly. The query in question is on line 812 in admin-functions.php.

    function page_rows( $parent = 0, $level = 0, $pages = 0, $hierarchy = true ) {
    global $wpdb, $class, $post;
    if (!$pages )
    $pages = get_pages( 'sort_column=post_name' );
    if (! $pages )
    return false;

    Anyone have any ideas how to get my pages sorted by their post_name? Thanks!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Just looking at the code seems the default is:
    'sort_column' => 'post_title'

    Thread Starter andrewkhunn

    (@andrewkhunn)

    That’s my altered attempt. The actual un-modified code is:

    function page_rows( $parent = 0, $level = 0, $pages = 0, $hierarchy = true ) {
    global $wpdb, $class, $post;
    if (!$pages )
    $pages = get_pages( 'sort_column=menu_order' );
    if (! $pages )
    return false;

    Sorry for the confusion.

    Thread Starter andrewkhunn

    (@andrewkhunn)

    Oh wait, are you saying just strip out the:

    'sort_column=post_name'

    and get_pages() should sort by name? I’ll try that real quick and see if it works.

    Thread Starter andrewkhunn

    (@andrewkhunn)

    No go.

    Thread Starter andrewkhunn

    (@andrewkhunn)

    Having re-read your post for the third time now Michael, the display default is post_title further on down the code from the snippet I posted, but for some reason it is obviously not sorting by that in the administration panel itself.

    Any other hints anyone?

    You used ‘post_name’ but I was saying ‘post_title’ and that’s the column name in wp_posts.

    Thread Starter andrewkhunn

    (@andrewkhunn)

    Replacing post_title with post_name does not fix the order. Already tried that. ??

    Thread Starter andrewkhunn

    (@andrewkhunn)

    I meant that the other way around. Sheesh.

    Thread Starter andrewkhunn

    (@andrewkhunn)

    Just for future reference, I finally found the code I needed to manipulate to get this working right:

    wp-admin/edit-pages.php: line 22
    wp('post_type=page&orderby=menuorder&what_to_show=posts&posts_per_page=-1&posts_per_archive_page=-1&order=asc');
    to
    wp('post_type=page&orderby=title&what_to_show=posts&posts_per_page=-1&posts_per_archive_page=-1&order=asc');

    Is there a way to display page slug name in page management?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Order “Manage Pages” by Name’ is closed to new replies.