Title: Combine two codes
Last modified: August 19, 2016

---

# Combine two codes

 *  [EnMiljon](https://wordpress.org/support/users/enmiljon/)
 * (@enmiljon)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/combine-two-codes/)
 * Okej soo I want to be able to display the title and custom field of childpages
   on my parent page
 * first of I have a code that display the childpages and it’s like this:
 *     ```
       <?php
       $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
       if ($children) { ?>
          <ul>
           <?php echo $children; ?>
       </ul>
       <?php } ?>
       ```
   
 * Then I have a code that shows custom field called custom_blurb that I want to
   add to the previuos code..
 *     ```
       <?php
       $pages = get_pages();
           foreach($pages as $page) {
               $custom_blurb = get_post_meta($page->ID, 'custom_blurb', true);
       	echo "<h3><a href=\"".get_page_link($page->ID)."\">$page->post_title</a></h3>";
       	echo $custom_blurb;
           }
       ?>
       ```
   
 * The reason I want to add it is that this custom image code display al pages. 
   Soo i want to put the custom flield code in the childpage code!
 * I’m a newbie on php coding would be really happy if someone could show me how
   I could combine these codes

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/combine-two-codes/#post-1659919)
 * Maybe this will help. you can use “child_of” in [get_pages()](http://codex.wordpress.org/Function_Reference/get_pages)
   as well
 *     ```
       <?php
        $pages = get_pages('child_of='.$post->ID);
           foreach($pages as $page) {
               $custom_blurb = get_post_meta($page->ID, 'custom_blurb', true);
       	echo "<h3><a href=\"".get_page_link($page->ID)."\">$page->post_title</a></h3>";
       	echo $custom_blurb;
           }
       ?>
       ```
   
 *  Thread Starter [EnMiljon](https://wordpress.org/support/users/enmiljon/)
 * (@enmiljon)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/combine-two-codes/#post-1659922)
 * THANKS:D that worked out great

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Combine two codes’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [EnMiljon](https://wordpress.org/support/users/enmiljon/)
 * Last activity: [15 years, 7 months ago](https://wordpress.org/support/topic/combine-two-codes/#post-1659922)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
