11 Aug 2017

Displaying advanced custom fields outside of the loop

Super easy - Just replace the post ID 123:

$value = get_field( "text_field", 123 );
echo $value;

More info here - and here's how to do it inside the loop.

What about repeater fields?

I'm glad you asked. Here's a PHP snippet to echo the values for a repeating field that I've called logo (just remember to change the ID 1862 to match the post or page ID):

while( have_rows('repeater', 1862) ): the_row(); 
  the_sub_field('logo'); 
endwhile;