I have a custom post type called 'suppliers' which is used to display a series of supplier's logos in the footer.
<?php $suppliers_loop = new WP_Query( array( 'post_type' => 'suppliers', 'posts_per_page' => 7 ) ); ?>
<?php if ($suppliers_loop->have_posts()):?>
<?php while ( $suppliers_loop->have_posts() ) : $suppliers_loop->the_post(); ?>
<?php $image = get_field('image');?>
<div class="col-1-7 mobile-col-1-4">
<a href="<?php echo(get_field('suppliers_url'))?>" target="_blank">
<img src="<?php echo $image['url'];?>" title="<?php echo $image['title'];?>" alt="<?php echo $image['alt'];?>"/>
</a>
</div>
<?php endwhile; ?>
<?php endif; ?>
This works well on every page of the site including other custom post type archives and categories apart from the standard WordPress category page? Where the loop returns:
<div class="col-1-7 mobile-col-1-4">
<a href="" target="_blank">
<img src="" title="" alt=""/>
</a>
</div>
If I replace echo $image['title']
with the_title()
it returns:
<div class="col-1-7 mobile-col-1-4">
<a href="" target="_blank">
<img src="" title="Digital White Ink" alt=""/>
</a>
</div>
<div class="col-1-7 mobile-col-1-4">
<a href="" target="_blank">
<img src="" title="Environment" alt=""/>
</a>
</div>
etc..
These returned titles are pages and other post types (some of which are in the bin)? Can anyone shed any light on what on earth is going wrong and how to rectify it?