Support » Requests and Feedback » Page Order Listing Bug Found

  • 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;
    }

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Page Order Listing Bug Found’ is closed to new replies.