Home Forums General Issues Get image loaded Reply To: Get image loaded

  • <?php
    $postMeta = get_post_meta($post->id);

    That should give you a print of all the custom fields attached to the post in a 'field_name' => 'field_value' array. This is just temporary code to find out the name of the field that holds the image information.

    Once you have identified the ‘field_name’ that is matched with your image ‘field_value’, do this:

    foreach ( $posts as $post ) {
       if (has_post_thumbnail($post->ID)) {
        $post_thumbnail_id = get_post_thumbnail_id( $post->ID );
        $homepage_secs.='<div class="thumb-container"><div class="thumb"><img class="image" src="'.$image_src[0].'" /></div></div>';
      $second_image = get_field('field_name', $post->ID);
      // do whatever you need to with the second image

    The difference between get_field() and the_field() is just that the_field() prints the field value to the screen immediately, whereas get_field() allows you to assign the result to a variable.