Can’t display the featured image (thumbnail) for subpages?
-
Hi everyone,
I’ve a question about the thumbnail-image (the_post_thumbnail).
I’ve a setting in my wordpress where I need to give each subpage a featured image. When I upload an image it saves in 6 different sizes. When I then need to extract my featured thumbnail image in the size I need, I use this line of code:
the_post_thumbnail('featured-wide')
The featured-wide is the name of the thumbnail cropped size I want, I also have ‘featued-small’, ‘featured-medium’ and so on – you get the picture.This is all fine and dandy when I e.g. work inside my loop where I list all subpages for a specific parent; it shows the thumbnail for each subpage and for the parent.
My problem is then that on my frontpage I want to display the newest subpage for three different parents and for that I use this line of code:
$pages = get_pages('child_of=54&sort_column=post_date&sort_order=desc');
I then have a foreach loop:foreach($pages as $page)
where I inside this loop extract the title and the page excerpt. But, mythe_post_thumbnail(‘featured-medium’)
does not work. It simply does display anything and after taken a var_dump of the $pages variable as mentioned before it doesn’t list it either. So my question is, is it possible and how, to extract the featured image from a subpage when doing it the way I do?Or is there a more efficient way to get the latest subpage of a given parent and then display the featured image?
Sincerely
– Mestika
- The topic ‘Can’t display the featured image (thumbnail) for subpages?’ is closed to new replies.