• I am trying to learn the Custom Field Template plugin which so far is great, I just wish there was full documentation somewhere. With the help of this board though I have learned a lot tonight. My question I think is simple, we shall see ??

    I am hoping someone can supply code that I can include in my template for a radio or checkbox field. I want the user to be able to check an option (ex. red, blue or green) and then depending on the option I can load a specific photo or text into the template.

    So what I need is the php code for the template that would include the conditional statement of whether a certain radio or checkbox field is selected. Does that make sense?

    Hopefully someone can help, thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Something like:

    <?php 
    
    $cft_option  = get_post_meta( $post->ID, 'your_field', true ); 
    
    if( !empty( $cft_option ) ) {
    
       if( $cft_option == 'red'){
       //.. do stuff if it's red
       }
    
       if( $cft_option == 'green'){
       //.. do stuff if it's green
       }
    
       if( $cft_option == 'blue'){
       //.. do stuff if it's blue
       }
    
    }
    
    ?>

    Thread Starter adam533

    (@adam533)

    Perfect, thank you so much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to display output of checkbox and radio fields using Custom Field Template’ is closed to new replies.