Home Forums ACF PRO Moving a template code into functions.php


Moving a template code into functions.php

  • Hello,
    I got this code in a template:

    						$images = get_field('my_gallery');
    							$size = 'thumbnail'; // (thumbnail, medium, large, full or custom size)
    							if( $images ): ?>
    									<?php foreach( $images as $image_id ): ?>
    											<?php echo wp_get_attachment_image( $image_id['ID'], $size ); ?>
    									<?php endforeach; ?>
    							<?php endif; ?>

    That displays gallery attachements in archive and single display.

    Because I would like to avoid modifying template, could you please advise of how to turn it into a hook or filter, that would place this code before “read more” link (but after rest of content) or if not possible right after it on archive display?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.