• Hey guys, I was hoping someone might be able to help with small piece of code.

    I have this:

    $slider_image_id = get_post_meta($product->ID, 'Slider Image', true);
     $post_image = wp_get_attachment_url($slider_image_id);

    which loads the page’s specified image that is put in a ‘custom field’ box.

    I was hoping I could put something like this:

    $slider_image_id = get_post_thumbnail_id( $post_id );
     $post_image = wp_get_attachment_image_src( $attachment_id );

    But of course I’m not an expert… it is more complicated as the images are from ‘child’ pages.

    You can see the code working here:

    https://www.vendome.com.au/products/faberge-jewellery/

    But I am having issues with the images loading in all IE.. sometimes/mostly they do not load.

    I am hoping that calling them in cleanly might help, can anyone help?

    Chrissy

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You can display the thumbnail by placing <?php echo get_the_post_thumbnail($post_id); ?> where you want the image to appear on your template. Similarly, <?php echo wp_get_attachment_image($attachment_id); ?> will do the same for an attached image.

    As you say, getting the attachment ID is a bit complicated. See Function Reference/get children for some examples on how to do that.

Viewing 1 replies (of 1 total)
  • The topic ‘help with get_post_thumbnail_id instead of get_post_meta? IE incompatible!?’ is closed to new replies.