• 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

    (@keesiemeijer)

    Maybe this will help. you can use “child_of” in 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

    (@enmiljon)

    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.