WordPress.org

Ready to get started?Download WordPress

Forums

Custom Field Template
How to display output of checkbox and radio fields using Custom Field Template (3 posts)

  1. adam533
    Member
    Posted 3 years ago #

    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!

  2. proximity2008
    Member
    Posted 3 years ago #

    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
       }
    
    }
    
    ?>
  3. adam533
    Member
    Posted 3 years ago #

    Perfect, thank you so much!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic