Image attachments don’t get detected
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
This is our free support forum. Replies can take several days.
Need fast email support? Get SiteOrigin Premium
Replies
3Hi 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.
Replies on this thread are closed.
Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.