Title: Using preg_replace to hack wp_list_pages
Last modified: August 19, 2016

---

# Using preg_replace to hack wp_list_pages

 *  Anonymous User 4116433
 * (@anonymized-4116433)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/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.

## Tags

 * [preg_replace](https://wordpress.org/support/topic-tag/preg_replace/)
 * [wp_list_pages](https://wordpress.org/support/topic-tag/wp_list_pages/)

 * 0 replies
 * 1 participant
 * Last reply from: Anonymous User 4116433
 * Last activity: [16 years, 8 months ago](https://wordpress.org/support/topic/using-preg_replace-to-hack-wp_list_pages/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
