This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

Image attachments don’t get detected

11 years ago · Last reply by Andrew Misplon 11 years ago

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

3
  1. Andrew Misplon Staff 11 years, 1 month ago

    Hi Fabio

    Thanks for reaching out.

    I’ll ask Greg or Braam if they can attend to this ASAP.

  2. Fabio Marzocca 11 years, 1 month ago

    Hi Misplon,

    I discovered my code was wrong. Now it is working!

    Thank you for you cooperation.

    Fabio

  3. Andrew Misplon Staff 11 years, 1 month ago

    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.

Have a different question or issue?

Start New Thread