WordPress.org

Make WordPress Core

Ticket #12945: 12945.2.diff

File 12945.2.diff, 1.2 KB (added by technosailor, 8 months ago)

Still a less than idea solution. Would be better if I had access to postnot_in, but... refreshed patch more cleanly fixes this issue. wp_page_menu() now includes a home link only, and respects if a user has designated a page for the front page. Filters remain in place for plugins to modify.

  • wp-includes/post-template.php

     
    893893 * @return string html menu 
    894894 */ 
    895895function wp_page_menu( $args = array() ) { 
    896         $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => ''); 
     896        $defaults = array( 'sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '' ); 
     897         
     898        // If A Page has been designated for the home page 
     899        if( get_option( 'page_on_front' ) != 0 ) { 
     900                $args['show_home'] = false; 
     901                $args['include'] = get_option( 'page_on_front' ); 
     902        } 
     903        // Default configuration. No home page specified 
     904        else { 
     905                $args['show_home'] = true; 
     906                $pages = get_posts( array( 'post_type' => 'page', 'posts_per_page' => -1 ) ); 
     907                $pids = array(); 
     908                foreach( $pages as $p ) { 
     909                        $pids[] = (int) $p->ID; 
     910                } 
     911                $args['exclude'] =  implode( ',', $pids ); 
     912        } 
     913 
     914         
    897915        $args = wp_parse_args( $args, $defaults ); 
    898916        $args = apply_filters( 'wp_page_menu_args', $args ); 
    899917