Wordpress / PHP Help Requested

2 replies
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
#php #requested #wordpress
  • Profile picture of the author Bruce Hearder
    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
    {{ DiscussionBoard.errors[1229103].message }}
  • Profile picture of the author davidmerrick
    I was actually just looking for the same thing in Wordpress and stumbled across this. Thanks guys!
    {{ DiscussionBoard.errors[1232535].message }}

Trending Topics