Support

Account

Home Forums General Issues Conditional Fields – Color or Image – Add Via Dynamic Style Sheet Reply To: Conditional Fields – Color or Image – Add Via Dynamic Style Sheet

  • 1) Absolutely. Set up the radio button field with two values: image and color (you can label them whatever you like). Set up the color picker field, set up the image field. Set the color and image fields to only display when the related radio button is selected via “Conditional Logic” at the bottom of their respective fieldsets.

    2) I’d probably do this with inline css to save the headache. Set any sort of global stuff in your stylesheet and then in the template something along the lines of this should get you going:

    
    <?php
    	$backgroundType = get_field('the-type-radio-button-field-name');
    
    	if ($backgroundType == "image"){
    		$style = "background-image: " . the_field('your-image-field-name');
    	} else { //it's a color
    		$style = "background-color: " . the_field('your-color-picker-field');
    	}
    ?>
    	<div style="<?php echo $style; ?>">
    		Content Here.
    	</div>