I want to get the URL of the Muffin Betheme subheader image of a child page, in the parent one, for each of its children.

Thus, I go through the children, then I try to get the subheader image for each child and I display it.

foreach (get_page_children(get_the_ID(), (new WP_Query())->query(array('post_type' => 'page', 'post_status' => 'publish'))) as $child) {

    $html_to_display .= '<a href="' . get_permalink($child) . '"><img src="' . wp_get_attachment_image_src($child->ID, 'large') . '" />' . get_the_title($child) . '</a>';


However, wp_get_attachment_image_src($child->ID, 'large') returns:


I checked out the subheader image of this child, and the upload actually exists.


How could I display this subheader image correctly?


What tags would you recommend me to use in this SO question?


Use get_the_post_thumbnail_url() instead of wp_get_attachment_image_src()

wp_get_attachment_image_src(): this function takes attachment id as first parameter

  • I replaced the line with: $html_to_display .= '<a href="' . get_permalink($child) . '"><img src="' . get_the_post_thumbnail_url($child, 'large') . '" />' . get_the_title($child) . '</a>';. Now it shows false instead of unkown – JarsOfJam-Scheduler Nov 12 '18 at 13:13
  • Have you attach image to child page? Function returns false if no URL is available – Aparna_29 Nov 12 '18 at 13:36
  • Yes, I attached a subheader image (field subheader image). Are you speaking about this image or the one attached to any page, indpendently of using the Muffin Betheme? – JarsOfJam-Scheduler Nov 12 '18 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.