Support » Themes and Templates » WP List Pages, Please help me edit this code

  • Using a theme called ‘Dark Classic’ at: http://www.swisshut.com/manners.

    I’m using the photobook module which displays all my galleries in the themes menu toolbar. I want to restrict this using wp_list pages. Have not had any luck!

    Author made this change to the wp_list_pages:

    function wp_list_pages2($limit=NULL) {
    
    	$defaults = array('depth' => 1, 'show_date' => '', 'date_format' => get_option('date_format'),
    		'child_of' => 0, 'exclude' => '5,6,7,8,9', 'title_li' =>'', 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title');
    	$r = array_merge((array)$defaults, (array)$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) ) {
    
    		for($i=0;$i<count($pages);$i++)
    		{
    			$output .='<div class="menu_sep">-</div><div><a href="'.get_page_link($pages[$i]->ID).'">'.$pages[$i]->post_title.'</a></div>';
    			if($limit!=NULL)
    			{
    				break;
    			}
    		}
    	}
    
    	$output = apply_filters('wp_list_pages', $output);
    
    	echo $output;
    }

    in the header file its then called like this:

    <div id="menu_items">
        	<div><a href="<?php echo get_option('home'); ?>/">Home</a></div><?php wp_list_pages2(); ?>
        </div>

    I’ve tried to add exclude tags, changing levels but never seems to show up perfect.

Viewing 6 replies - 1 through 6 (of 6 total)
  • I find I can get it pretty close using the standard WP_list_pages call but for some reason I get some random bullets showing up and messing up the menu options.

    In the code it says something about “Allow plugins to filter an array of excluded pages” I’m hoping this may help?

    I am using this code

    ‘<div id=”menu”>
    <div id=”menu_items”>
    <div>/”>Home</div><?php wp_list_pages(‘title_li=<h1>’ . ‘</h1>&sort_column=ID&depth=1’); ?>
    </div>’

    Now it only shows one bullet! How can I get rid of this please? 🙁

    Screenshot:
    http://share.webcommand.org/Share/images/445672wp.jpg

    Jeff Chandler

    (@jeffr0)

    Volunteer Moderator and Voice of WP

    Have you checked out the codex article related to this function?

    Yes I have gone through it about 30 times and tried many different variations but just can not get that damn little bullet to go away! 🙁

    GuruXL

    (@guruxl)

    Did you try CSS styling using the html>ul li selector?

    ektz

    (@ektz)

    yeah you should particularly style the ul li tag’s css for menu. if you could send me the code for showing the page navi, i would be able to help u better.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘WP List Pages, Please help me edit this code’ is closed to new replies.