Some (but not all) images are not showing. (3 posts)

  1. surfsup74
    Posted 2 years ago #

    This is very frustrating - I have a loop (below) that's getting only some of the images paths whilst missing others. So I get loads (but not all) of broken images throughout the page. This is hard to troubleshoot as I am getting some images. I just get <img src="" /> on the ones where it chooses to miss it.
    I'm using Advanced Custom Fields plugin to create the fields.

                $types[0] = 'media-tags';
                foreach ($types as $type) {
                 $terms = get_terms($type, array('name_like' => "a", 'order' => 'DESC', 'orderby' => 'count' ) );
                 if ($terms) {
                  foreach($terms as $term) {
                      $image = wp_get_attachment_image_src(get_field('image_tag', 'media-tags_'.$term->term_id.''), 'thumbnail');
                   echo '<li>
                            <a href="http://domain.com/archive/photographs/'.$term->slug.'">
                            <img src="'.$image[0].'"/><div>
                   echo '<h2>'.$term->name.'</h2>								</div>
  2. surfsup74
    Posted 2 years ago #


    I have noticed (by chance) that if I put the same loop into my template file used to display 'taxonomy' pages it then outputs all the images as I want. However - if I use the same loop on my template file for 'pages' (which is where I need it) it will only display some (but not all) images.

    Weird, but I expect there's a simple explanation?


  3. surfsup74
    Posted 2 years ago #

    Found the problem - I had previously named another field and the loop wa pulling in images for that field name! All sorted.

Topic Closed

This topic has been closed to new replies.

About this Topic