calling featured images from child pages
-
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 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘calling featured images from child pages’ is closed to new replies.