Using preg_replace to hack wp_list_pages
-
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?
The topic ‘Using preg_replace to hack wp_list_pages’ is closed to new replies.