Code Samples /

Custom Fields

To access custom field values in a Repeater Template you must define global $post; at the top of the repeater and pass the $post->ID to the custom field function.

<?php global $post; ?>
<li>
	<?php
   // Standard.
	$value = get_post_meta( $post->ID, 'custom_field_name', true );
	
	// Advanced Custom Fields.
	$value = get_field( 'custom_field_name', $post->ID ); 	
	?>
</li>
PHP

Pro Tip: Don’t forget to declare global $post; at the opening of your template


« Back to Code Samples