WordPress.org

Ready to get started?Download WordPress

Forums

Modifying function that generates the html for wp_list_pages help (1 post)

  1. charlene2021
    Member
    Posted 6 years ago #

    In order to get the code for my navigation to work I am going to have to fix the way the html for wp_list_pages is outputted.

    The code looks like:

    <ul class="menu">
    <li><a href="#nogo"><b><span>HOME</span></b><em></em></a></li>
    <li><a href="#nogo"><b><span>ABOUT</span></b><em></em></a></li>
    <li><a href="#nogo"><b><span>STUFF</span></b><em></em></a></li>
    <li><a href="#nogo"><b><span>GALLERY</span></b><em></em></a></li>
    <li><a href="#nogo"><b><span>DOMAIN</span></b><em></em></a></li>
    <li><a href="#nogo"><b><span>EXIT</span></b><em></em></a></li>
    </ul>

    I see in post_template

    function wp_list_pages($args = '') {
    	if ( is_array($args) )
    		$r = &amp;$args;
    	else
    		parse_str($args, $r);
    
    	$defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'),
    		'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title');
    	$r = array_merge($defaults, $r);
    
    	$output = '';
    	$current_page = 0;
    
    	// sanitize, mostly to keep spaces out
    	$r['exclude'] = preg_replace('[^0-9,]', '', $r['exclude']);
    
    	// Allow plugins to filter an array of excluded pages
    	$r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', explode(',', $r['exclude'])));
    
    	// Query pages.
    	$pages = get_pages($r);
    
    	if ( !empty($pages) ) {
    		if ( $r['title_li'] )
    			$output .= '<li class="pagenav">' . $r['title_li'] . '
    <ul>';
    
    		global $wp_query;
    		if ( is_page() )
    			$current_page = $wp_query->get_queried_object_id();
    		$output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
    
    		if ( $r['title_li'] )
    			$output .= '</ul>
    </li>
    ';
    	}
    
    	$output = apply_filters('wp_list_pages', $output);
    
    	if ( $r['echo'] )
    		echo $output;
    	else
    		return $output;
    }

    but since I don't know PHP that well I don't know how to configure it.

    BTW Thanks to Stuart of CSSplay for his awesome navigation menu I am trying to implement.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.