Forums

Using preg_replace to hack wp_list_pages (1 post)

  1. roygbiv
    Member
    Posted 2 years ago #

    I need to query child pages and contain them in a select list; I thought wp_list_pages would be able to do this with the right degree of customization. Turns out, I couldn't find a way to list pages without the li and a tags. A pretty hackified solution:

    <select>
    <?php echo preg_replace('@\<li([^>]*)>\<a([^>]*)>(.*?)\<\/a>\<\/li>@i', '<option value="<?php the_permalink() ?>">$3</option>', wp_list_pages('echo=0&orderby=name&title_li=&child_of=40')); ?>
    </select>
    <input type="submit" value="Go" name="btn"/>

    Clearly, the_permalink doesn't work here. Does anyone have any advice on the best way to pass along the page permalink?

Topic Closed

This topic has been closed to new replies.

About this Topic