Support » Fixing WordPress » Some (but not all) images are not showing.

  • 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.

    <?php
                $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>
                                                <div>';
                   echo '<h2>'.$term->name.'</h2>								</div>
                                            </div>
                                        </a>
                                    </li>';
                 }
                }
                }
                ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • *Update*

    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?

    Thanks,

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Some (but not all) images are not showing.’ is closed to new replies.