Forums

Showing a custom field value of a child page on a parent (1 post)

  1. trixienolix
    Member
    Posted 7 months ago #

    I have a parent page and some child pages. The child pages are assigned a custom field value. I want to show these child page custom field values on the parent page.

    How do I do this?

    here's the code I'm using to list the child pages, plus a non-working go at getting the child custom field (called job_title)

    <?php
    	$mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'desc' ) );
    	foreach( $mypages as $page ) {
    		$content = $page->post_content;
    		if ( ! $content ) // Check for empty page
    			continue;
    		$content = apply_filters( 'the_content', $content );
    	?>
    		<li><a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo $page->post_title; ?></a> - <?php echo get_post_meta($post->post_child, 'job_title', true); ?></li>
    	<?php
    	}?>

    thanks in advance

Reply

You must log in to post.

About this Topic