Skip to content

Instantly share code, notes, and snippets.

@emaildano
Created May 28, 2014 20:15
Show Gist options
  • Save emaildano/6b6c47ec2bc3be54fcc6 to your computer and use it in GitHub Desktop.
Save emaildano/6b6c47ec2bc3be54fcc6 to your computer and use it in GitHub Desktop.
ACF field counter snippet.
<?php
// get the count on the repeater field
// mabye use get_sub_field() instead of get_field() if it's nested
$count = count( get_sub_field( 'the_field' ) );
// begin $count conditions
if ( $count > 1 ) { ?>
// greater than 1
<?php the_field( 'great_than_1' ); ?>
<?php } else { ?>
// less than 1
<?php the_field( 'less_than_1' ); ?>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment