Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

damian.smith on "calling featured images from child pages"

$
0
0

Hey guys I have this function below, that calls the information of child pages into the parent page. All works perfectly except the featured images act strangely.

The featured imahes should sit inside the featured-img div but for some reason they all sit outside of the ul completely, like so:

<img...../>
<ul class="childrens">
<li>.... etc etc</li>
</ul>

Any ideas?? :/

function get_children() {
	global $post;

	$args = array(
		'post_parent' => $post->ID,
		'post_type' => 'page'
	);
	$subpages = new WP_query($args);

	// create output
	if ($subpages->have_posts()) :
		$output = '<ul class="childrens">';
		while ($subpages->have_posts()) : $subpages->the_post();
			$output .= '<li>
						<div class="featured-img">'.the_post_thumbnail().'</div>
						<div class="childrens-content">
						<h3><a href="'.get_permalink().'">'.get_the_title().'</a></h3>
						<p>'.get_the_excerpt().'<br />
						</div>
						<a class="read-more" href="'.get_permalink().'">Read More > ></a></p>
						</li>';
		endwhile;
		$output .= '</ul>';
	else :
		$output = '<p>No subpages found.</p>';
	endif;

	// reset the query
	wp_reset_postdata();

	// return something
	return $output;
}

Viewing all articles
Browse latest Browse all 8245

Trending Articles