Hi,
I'm trying to pull an image from a child page on to a parent page. I am unsure on how to do this. I am using a piece of code I found elsewhere in the forum that displays child pages as posts (it works great for the content), and I'm generating the image using magic fields.
i've used this method previously, but not with a child page set up.
<?php $postImg = get_post_meta($post->ID, 'book-image', $single = true);?>
So far, I have this...
<?php
$pages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc');
$count = 0;
foreach($pages as $page)
{
$content = $page->post_excerpt;
if(!$content)
continue;
if($count >= 2)
break;
$count++;
$content = apply_filters('the_content', $content);
?>
<h2><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h2>
<div class="postImg">
<?php $postImg = get_post_meta($post->ID, 'book-image', $single = true);?>
<img src="<?php echo $postImg;?>" alt="<?php echo the_title();?>" />
</div>
<div class="entry"><?php echo $content ?></div>
<div class="clear"></div>
<div class="orangeLink"><a href="<?php echo get_page_link($page->ID) ?>">Check This Out</a></div>
<?php
} ?>
I've tried working the $postImg bit into the top, but to no avail, and my programming is pretty basic. Any suggestions would be welcomed.
Thanks