mardi 31 mars 2015

Outdated attachments loop in Wordpress

I have a client that has run into issues when they updated Wordpress. Basically a loop designed to pull in media attachments with a walker, e.g. pull the latest media attachment into the latest post, is no longer working.


Here's the loop:



<?php
$attachments = attachments_get_attachments();
$total_attachments = count($attachments);
?>
<?php if( $total_attachments > 0 ) : ?>
<?php for ($i=0; $i < $total_attachments; $i++) : ?>
<a href="<?=$attachments[$i]['location']?>" title="<?=$attachments[$i]['caption']?>" class="lightbox" rel="<?php the_ID(); ?>"><img src="<?=$attachments[$i]['location']?>" alt="<?=$attachments[$i]['caption']?>" class="attachment-thumbnail" /></a>

<?php endfor ?>
<?php endif ?>


I need to change this so that it works with the current version of Wordpress as of 2015.


Has anyone here encountered this before?


Many thanks, Jake


Aucun commentaire:

Enregistrer un commentaire