• Resolved guided

    (@guided)


    Hi,

    I’m working with a theme I did not design, and trying to use the include function in a modified wp_list-pages call. It’s not working. Three pages should be listed, only one is. The problem is with holidayfu.com

    I declare

    <?php wp_list_pages2('include=2,190,303'); ?>

    but only page 2 is displayed, so 190 and 303 are not.

    wp_list_pages2 is a theme function. The function is defined thus:

    function wp_list_pages2($limit=NULL) {
    
    	$defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'),
    		'child_of' => 0, 'exclude' => '', 'title_li' =>'', 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title');
    	$r = array_merge((array)$defaults, (array)$r);//make sure using the type conversion when you're using php5
    
    	$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><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;
    }

    Any help would be greatly appreciated.

    Thanks,
    Iain

Viewing 7 replies - 1 through 7 (of 7 total)
  • If you just use the template tag, wp_list_pages(), what happens?

    Thread Starter guided

    (@guided)

    It works, as in it calls the right pages, but they appear one below the other, instead of one next to the other. They are also misaligned.

    Here’s the css:

    #menu{
    	width:380px;
    	float:right;
    }
    
    #menu_items{
    float:right;
    padding:90px 0px 0px 0px;
    }
    
    #menu_items div{
    display:block;
    float:left;
    color:#000;
    padding-left: 10px;
    }
    
    div#menu #menu_pad{
    	font-family:Verdana, Arial, Helvetica, sans-serif;
    	font-size:12px;
    	padding-right:17px;
    	color:#fff;
    	float:right;
    	width:100%;
    }
    
    div#menu a{
    	color:#000;
    	line-height:14px;
    }
    
    div#menu a:hover{
    	color:#ea1c24;
    }
    
    div#menu #menu_items div{
    	height:22px;
    }
    
    div#menu #menu_items div:hover{
    	color:#333;
    }

    Well your custom function doesn’t seem to be getting the list of arguments correctly. Shouldn’t this code:

    wp_list_pages2($limit=NULL)

    be something like:

    wp_list_pages2($r)

    Thread Starter guided

    (@guided)

    Thanks for your help Michael. I’ve tried that, and something happened. All pages are now diplayed (go to holidayfu.com to see what I mean), so the include call still isn’t working. Any ideas? I’m completely lost.

    Thread Starter guided

    (@guided)

    Would adding something to the function help?

    You might check the value of $r. Put this:

    echo "<pre>"; print_r($r); echo "</pre>";

    right before:

    $pages = get_pages($r);

    to see if the include argument is there.

    Thread Starter guided

    (@guided)

    No, the include argument isn’t there. But the exclude argument is there, and it doesn’t work. Here’s what was diplayed:

    <pre>Array
    (
        [depth] => 0
        [show_date] =>
        [date_format] => F j, Y
        [child_of] => 0
        [exclude] =>
        [title_li] =>
        [echo] => 1
        [authors] =>
        [sort_column] => menu_order, post_title
        [0] => include=2,190,303
    )
    </pre>

    I’ve gone around this by using the exclude pages plugin, which is called by the funtion. It worked!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘‘Include=’ not working with modified wp_list_pages’ is closed to new replies.