Title: Conditional Statement (Advanced Custom Fields)
Last modified: August 20, 2016

---

# Conditional Statement (Advanced Custom Fields)

 *  Resolved [cmdshiftdesign](https://wordpress.org/support/users/cmdshiftdesign/)
 * (@cmdshiftdesign)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/conditional-statement-advanced-custom-fields/)
 * Using the Advanced Custom Fields plugin with the Repeater add-on. ([http://www.advancedcustomfields.com](http://www.advancedcustomfields.com))
 * I have repeated field called “lists’ and within that a sub field called ‘spcl’
 * I want a conditional statement w/in my template saying …. IF ‘spcl’ is there,
   
   DO THIS if not DO NOTHING
 * since i am dealing with a subfield, im having trouble getting this to check for
   first the list field and then the sub field.. this is what i have right now…
 *     ```
       <?php
       if(get_field('lists') && get_sub_field('spcl'))
       {
       	echo '<p>POOP!</p>';
       }
       ?>
       ```
   

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [Andrew Norcross](https://wordpress.org/support/users/norcross/)
 * (@norcross)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/conditional-statement-advanced-custom-fields/#post-2816838)
 * While I’ve never heard of the plugin before now, their documentation is pretty
   straight forward. Give this a shot:
 *     ```
       <?php
   
       $lists	= get_field('lists');
       $spcl 	= get_sub_field('spcl');
   
       if( ($lists) && ($spcl) )
       {
       	echo '<p>POOP!</p>';
       }
       ?>
       ```
   
 *  Thread Starter [cmdshiftdesign](https://wordpress.org/support/users/cmdshiftdesign/)
 * (@cmdshiftdesign)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/conditional-statement-advanced-custom-fields/#post-2816844)
 * Thanks, but no dice.
 * w/ my solution and this i can get it to work if i cam only calling for the ‘lists’
   field, but once i also ask for the sub_field ….nope :/ GRF!
 * Again, thanks though!
 *  [Andrew Norcross](https://wordpress.org/support/users/norcross/)
 * (@norcross)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/conditional-statement-advanced-custom-fields/#post-2816862)
 * Without seeing the rest of the code, I’d say that since it’s a repeating field,
   it’s probably being stored in an array and thus has to be broken out with a foreach.
 *  [Chris Everson](https://wordpress.org/support/users/chriseverson/)
 * (@chriseverson)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/conditional-statement-advanced-custom-fields/#post-2816872)
 * What do you get when you try to echo out the conditional functions?
 *     ```
       <?php
   
       echo get_field('lists');
       echo get_sub_field('spcl');
   
       ?>
       ```
   
 * Do you get values for both? Also, does it maybe not process the HTML markup? 
   Try removing the paragraph tags?
 * Good luck lady! Feel free to shoot me credentials via email or whatever if you
   don’t figure it out within a couple hours. Should be home from work by then and
   available to toy with it.
 *  [George Stephanis](https://wordpress.org/support/users/georgestephanis/)
 * (@georgestephanis)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/conditional-statement-advanced-custom-fields/#post-2816930)
 * You’re gonna want to look at this documentation, as you’re on a repeater field(
   which is inherently different):
 * [http://www.advancedcustomfields.com/docs/code-examples/#wpshdo_7](http://www.advancedcustomfields.com/docs/code-examples/#wpshdo_7)
 * So you’d do something like …
 *     ```
       $lists = get_field( 'lists' );
       if( $lists ){
       	foreach( $lists as $list ){
       		if( $list['spcl'] ){
       			echo '<p>POOP!</p>';
       		}
       	}
       }
       ```
   
 * it should trigger once for each instance of the repeater field, if spcl isn’t
   blank
 *  Thread Starter [cmdshiftdesign](https://wordpress.org/support/users/cmdshiftdesign/)
 * (@cmdshiftdesign)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/conditional-statement-advanced-custom-fields/#post-2817020)
 * Hey Dudes! Was JUST now able to get back to working on this and George, you win
   today!
 * Thanks to all of you! <3
 *  [Chris Everson](https://wordpress.org/support/users/chriseverson/)
 * (@chriseverson)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/conditional-statement-advanced-custom-fields/#post-2817063)
 * Oh yeah, that too. George wins!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Conditional Statement (Advanced Custom Fields)’ is closed to new replies.

## Tags

 * [conditional](https://wordpress.org/support/topic-tag/conditional/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 4 participants
 * Last reply from: [Chris Everson](https://wordpress.org/support/users/chriseverson/)
 * Last activity: [13 years, 12 months ago](https://wordpress.org/support/topic/conditional-statement-advanced-custom-fields/#post-2817063)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
