admin管理员组文章数量:1133739
I've added some custom fields to a rest route. I want to retrive the post thumbnail for my CPT and I'm using this code:
This is the code I'm using to add the post meta to the CPT after an image is selected and the post is published. If not clear I'm not using the default WP UI but a customnized one based on vue.js
$post_published = wp_update_post(
array(
'ID' => $post_id,
'meta_input' => array(
'post_thumbnail' => get_the_post_thumbnail_url( $post_id )
),
'post_status' => 'publish'
),
true,
true
);
The url will look like this
localhost/wp-content/uploads/23/09/myimage.png
and into the wp-admin custom dashboard the system will try to load this kind of url http://localhost/mysite/wp-admin/localhost/mysite/resources/uploads/2023/09/customimage-min-2.png
Anyway I've noticed that in my customized wordpress dashboard the link will be loaded in a wrong way, by inspecting the DOM I've noticed that the url of the thumbnail will be appended to the wp-admin one and this will result in a failed load. Is there a way to fix this?
本文标签: post thumbnailsUnable to get the correct URL using getthepostthumbnailurl() in wpadmin
版权声明:本文标题:post thumbnails - Unable to get the correct URL using get_the_post_thumbnail_url() in wp-admin 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736786420a1952887.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论