I had Wordpress 2.7 installed, and was using a function that would list all the children of the given page ID, but would remove the link (<a> tag) from the the parent links…
It’s a site for a church, and under the “about us” section, they have 4 area’s of information, Doctrine, Foursquare, Leadership, and New Life. Each of those pages have children giving more information about that area…
Here’s what it looks like:
http://www.nlfe.org/wordpress/about-us
My problem is that before upgrading to wordpress 3.0, the function that i’m using worked perfectly. It would remove the links from the parent links of the 4 area’s… but ever since I’ve upgraded I haven’t been able to figure out why it dosen’t remove the links anymore…
Any suggestions would be great. And if none of this makes sense… I can try to clear up the problem alittle bit, just let me know…
Here’s the code:
functions.php
function aboutChildren($id) {
$pages = wp_list_pages('child_of='.$id.'&title_li=');
$pages = explode("</li>", $pages);
$count = 0;
foreach($pages as $page) {
if(strstr($page,"<ul>")) {
$page = explode('<ul>', $page);
$page[0] = str_replace('</a>','',$page[0]);
$page[0] = preg_replace('/\\<a(.*)\\>/','',$page[0]);
if(count($page) == 3) {
$page[1] = str_replace('</a>','',$page[1]);
$page[1] = preg_replace('/\\<a(.*)\\>/','',$page[1]);
}
$page = implode('<ul>', $page);
}
$pages[$count] = $page;
$count++;
}
$pages = implode('</li>',$pages);
echo $pages;
}
Here’s how I’ve used it in the template file:
<ul class="listSections">
<?php
//$children = wp_list_pages('child_of='.$post->ID.'&title_li=');
$children = aboutChildren($post->ID);
if ($children) {
echo $children;
} ?>
</ul>
Thanks again!