Support

Account

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

Unread

Moving a template code into functions.php

  • Hello,
    I got this code in a template:

    					<?php 
    						$images = get_field('my_gallery');
    							$size = 'thumbnail'; // (thumbnail, medium, large, full or custom size)
    							if( $images ): ?>
    								<ul>
    									<?php foreach( $images as $image_id ): ?>
    										<li>
    											<?php echo wp_get_attachment_image( $image_id['ID'], $size ); ?>
    										</li>
    									<?php endforeach; ?>
    								</ul>
    							<?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)

The topic ‘Moving a template code into functions.php’ is closed to new replies.