Title: WordPress Loop Code to WordPress Widget
Last modified: August 20, 2016

---

# WordPress Loop Code to WordPress Widget

 *  [philjohns24](https://wordpress.org/support/users/philjohns24/)
 * (@philjohns24)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/wordpress-loop-code-to-wordpress-widget/)
 * Ok.. here goes.
 * Lets say I have the following code working to show the child pages of a parent
   page (and inline child pages of current child page):
 *     ```
       <?php
         if($post->post_parent)
         $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
         else
         $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
         if ($children) { ?>
         <ul>
         <?php echo $children; ?>
         </ul>
         <?php } ?>
       ```
   
 * How can I turn this into a wordpress widget/plugin so that all I have to do to
   make it visible on a page is drag and drop the new, corresponding widget into
   the sidebar?
 * Thanks,
 * Phil

Viewing 1 replies (of 1 total)

 *  Thread Starter [philjohns24](https://wordpress.org/support/users/philjohns24/)
 * (@philjohns24)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/wordpress-loop-code-to-wordpress-widget/#post-2180819)
 * Anyone got any ideas?

Viewing 1 replies (of 1 total)

The topic ‘WordPress Loop Code to WordPress Widget’ is closed to new replies.

## Tags

 * [Create widget](https://wordpress.org/support/topic-tag/create-widget/)

 * 1 reply
 * 1 participant
 * Last reply from: [philjohns24](https://wordpress.org/support/users/philjohns24/)
 * Last activity: [14 years, 9 months ago](https://wordpress.org/support/topic/wordpress-loop-code-to-wordpress-widget/#post-2180819)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
