Support » Fixing WordPress » trouble with wp_list_pages

  • I am trying to edit the “page.php” file in my theme with the following code to display only the child pages of the current page-

    			$children = wp_list_pages('title_li=Pages&child_of='.$post->ID.'&echo=0');
    			if ($children) { ?>
    			<?php echo $children; ?>
    			<?php } ?>

    This is taken straight off of this codex page-

    What happens though is I get two sets of unordered lists like in the below code. I want it to appear like the first set where it is only the child-pages of the current parent, but as you can see, the first url does not obey the ‘title_li=Pages’ that I put into the wp_list_pages(), the second ul does. But the second ul displays the parent, siblings and child pages. What the heck is going on?

    I can get rid of the if() and then it only displays the first unordered list but that still doesn’t fix the problem of it not obeying my title_li .. HELP!?!

    <li><strong><a title="Culture and fine arts" href="" target="_self">Culture and Fine Arts </a></strong></li>
    <li><a title="Leisure activities" href="" target="_self"><strong>Leisure Activities</strong> </a></li>
    <li><strong><a title="Urban Living" href="" target="_self">Urban Living</a> </strong></li>
    <li><strong><a title="Events" href="" target="_self">Events </a></strong></li>
    <p> </p>
    			<li class="pagenav">Pages<ul><li class="page_item page-item-52"><a href="" title="Go Green!">Go Green!</a></li>
    <li class="page_item page-item-47"><a href="" title="Culture and Fine Arts">Culture and Fine Arts</a>
    	<li class="page_item page-item-42"><a href="" title="Art">Art</a></li>
    	<li class="page_item page-item-43"><a href="" title="History">History</a></li>
    	<li class="page_item page-item-44"><a href="" title="Literature">Literature</a></li>
    	<li class="page_item page-item-45"><a href="" title="Music">Music</a></li>
    	<li class="page_item page-item-46"><a href="" title="Theatre">Theatre</a></li>
    <li class="page_item page-item-24"><a href="" title="Leisure Activities">Leisure Activities</a></li>
    <li class="page_item page-item-28"><a href="" title="Urban Living">Urban Living</a></li>
    <li class="page_item page-item-50"><a href="" title="Nightlife">Nightlife</a></li>
    </ul></li>			</ul>

  • The topic ‘trouble with wp_list_pages’ is closed to new replies.