Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   Wordpress / PHP Help Requested (https://www.warriorforum.com/programming/129078-wordpress-php-help-requested.html)

Lisa Copen 28th September 2009 08:45 PM

Wordpress / PHP Help Requested
 
Is there a way to remove the link part of wp_list_pages, leaving only the text apart?
< li >< a href=*** >Page Title < /a >< /li > ----> < li >Page Title< / li >

I want to created a bulleted list of a level of pages on my site, but I don't want them to be hyperlinked. Is this possible? Do I need to use some kind of regular expression replacement? I've tried a few, but it did not strip out the link.

Or is there maybe another function that will give me just the list of titles?

Thanks!

Lisa

Bruce Hearder 29th September 2009 02:40 AM

Re: Wordpress / PHP Help Requested
 
Hi Lisa,

I think this code snippet will do what you want (or at least get you on the right path):


$pages = wp_list_pages('depth=1&title_li=&echo=0');
if ($pages)
{
if (preg_match_all('/<a [^>]+>(.*)<\/a>/Uis', $pages, $array))
{
$titlesarray = $array[1];
foreach ($titlesarray as $title)
echo '<strong>'.$title.'</strong><br>';
}
}

I hope this helps

Bruce

davidmerrick 30th September 2009 03:25 AM

Re: Wordpress / PHP Help Requested
 
I was actually just looking for the same thing in Wordpress and stumbled across this. Thanks guys!


All times are GMT -6. The time now is 09:29 PM.