Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6371431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:04:06+00:00 2026-05-25T01:04:06+00:00

Ive given my wordpress user a custom field in the backend which is a

  • 0

Ive given my wordpress user a custom field in the backend which is a radio selection with three values, 1,2,3.

I want to set up conditionals so that if they select 1 then image 1 appears, if they select 2 then image 2 appears and if they select 3 then image 3 appears.

I’m currently using the following displays all thvalues of the checked buttons – but I need to use do do something like if value = 1 then do this

<?php 
/** Get a custom field with multiple values and return as an array */
$checkboxes_1 = get_custom_field('cft_checkboxes_1');
if( $checkboxes_1 ) {
?>
<div id="block-1" class="content-box"> 
<h2>Custom Field (multiple)</h2> 
<div class="entry"> 
    <?php print_r($checkboxes_1); ?> 
</div>
</div> 
<?php } ?>

the custome fields are generated using the custom field template button, and the implementation of getting the results is down to kevin leary

I’ve put this in my functions.php to retreive the cutom fields from the database…

// Get Custom Field Template Values
function get_custom_field($field) {
global $post;
$custom_field_data = get_post_meta($post->ID, $field, false);
if($custom_field_data) {
    if( count($custom_field_data) > 1 ) {
        return $custom_field_data; 
    } else {
        return $custom_field_data[0];
    }
} else {
    return false;
}
}

thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:04:07+00:00Added an answer on May 25, 2026 at 1:04 am

    Ok sorted it thanks for a great hack kevin leary for an amazing plugin: custom_field_templates

    <?php 
    /** Get a custom field with multiple values and return as an array */
    $checkboxes_1 = get_custom_field('mycustomfield');
    if(($checkboxes_1 ) == 1) {
    ?>
    // do something
    <?php } else if(($checkboxes_1 ) == 2) {?>
    // do something
    <?php } else if(($checkboxes_1 ) == 3) { ?>
    // do something
    <?php } ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to display some values from custom tables in wordpress. This is
I've been given a copy of a proposed site agreement in which one of
I'm trying to customize a wordpress page to include an iframe which give the
Ive managed to parse the entire contents of a given input text file and
Ive got a bunch of rectangular objects which I need to pack into the
I have jQuery for a WordPress theme I'm building. I've given up for now
I have some code (it's part of a wordpress plugin) which takes a text
I am starting to develop a site which basically acts as WordPress MU, in
I have 2 slideshows which should look like this . The user will upload
I'm currently creating a Wordpress theme and I have an area which displays the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.