Notice: This thread is over two years old; the information may be outdated. Please consider creating a new thread if you require free support. If you have an active SiteOrigin Premium license, you can email our premium support desk at [email protected].
This simple code snippet is detecting the first image attached to the post:
$images = get_posts( array( 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_parent' => $post->ID, 'posts_per_page' => 1, ) );?> wp_get_attachment_image($images[0]->ID );
It works on any post, except those with a page-builder structure. It seems that Page Builder hides the attached image from the function wp_get _attachment_image
Any tip?
Thanks
Fabio
Hi Fabio
Thanks for reaching out.
I’ll ask Greg or Braam if they can attend to this ASAP.
Hi Misplon,
I discovered my code was wrong. Now it is working!
Thank you for you cooperation.
Fabio
Awesome, really glad to hear you made progress here.
It might not be related but Braam was going to suggest the following:
Maybe double check that the images you’re trying to find are definitely attached to the posts in which you’re trying to find them. An image can be inserted into a post without being attached to that post. In other words, if you uploaded the image while editing the post with a Page Builder layout, it will be attached to that post. If it was previously uploaded elsewhere it will not be attached to the Page Builder post.
I’m just pasting that for information sake.