$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>WordPress Betheme: Unkown subheader image of a child page|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

WordPress Betheme: Unkown subheader image of a child page

matteradmin8PV0评论

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:

Unknown

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

Question

How could I display this subheader image correctly?

Metaquestion

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

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:

Unknown

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

Question

How could I display this subheader image correctly?

Metaquestion

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

Share Improve this question asked Nov 12, 2018 at 11:31 JarsOfJam-SchedulerJarsOfJam-Scheduler 1012 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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

Post a comment

comment list (0)

  1. No comments so far