WordPress.org

Ready to get started?Download WordPress

Forums

Page Order Listing Bug Found (2 posts)

  1. beholder38
    Member
    Posted 8 years ago #

    I found a bug in the page order listing on the sidebar menu. After some investigation, I tracked it down to the template-functions-post.php file in the wp-includes directory. The function &get_pages incorrectly sorted the pages by 'post_title' - by changing this to 'menu_order', the problem was corrected and the pages listed properly by the menu order field. The corrected code (denoted by // correction) is listed below.

    function &get_pages($args = '') {
    global $wpdb;

    parse_str($args, $r);

    if ( !isset($r['child_of']) )
    $r['child_of'] = 0;
    // correction
    if ( !isset($r['sort_column']) )
    $r['sort_column'] = 'menu_order';
    // end correction
    if ( !isset($r['sort_order']) )
    $r['sort_order'] = 'ASC';

    $exclusions = '';
    if ( !empty($r['exclude']) ) {
    $expages = preg_split('/[\s,]+/',$r['exclude']);
    if ( count($expages) ) {
    foreach ( $expages as $expage ) {
    $exclusions .= ' AND ID <> ' . intval($expage) . ' ';
    }
    }
    }

    $pages = $wpdb->get_results("SELECT * " .
    "FROM $wpdb->posts " .
    "WHERE post_status = 'static' " .
    "$exclusions " .
    "ORDER BY " . $r['sort_column'] . " " . $r['sort_order']);

    if ( empty($pages) )
    return array();

    // Update cache.
    update_page_cache($pages);

    if ( $r['child_of'] )
    $pages = & get_page_children($r['child_of'], $pages);

    return $pages;
    }

  2. Kafkaesqui

    Posted 8 years ago #

    1. What you have there is *not* a bug. The 'sort_column' argument is a parameter you can modify through the wp_list_pages() template tag:

    http://codex.wordpress.org/Template_Tags/wp_list_pages

    (See the Parameters list)

    2. *Actual* WordPress bugs should be reported at:

    http://trac.wordpress.org

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags