admin管理员组文章数量:1130349
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 badges1 Answer
Reset to default 0Use 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 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 badges1 Answer
Reset to default 0Use 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
本文标签: WordPress Betheme Unkown subheader image of a child page
版权声明:本文标题:WordPress Betheme: Unkown subheader image of a child page 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749190247a2330069.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论