Support » Plugins and Hacks » Toolset Types » Conditional w/ radio and checkboxes

Conditional w/ radio and checkboxes

  • I have a conditional statement which only shows data if the user selected items in a checkbox list. I have another section that does this for radio buttons.

    The problem I’m having is when I try to display the data on the front end (if the user selected any checkboxes), it just outputs the word “array”. Here’s my code:

    <?php if (!((get_post_meta($post->ID, 'wpcf-exterior-types', TRUE))=='')) {
    	echo '<p><strong>Exterior Types: </strong>'.get_post_meta($post->ID,'wpcf-exterior-types',TRUE).'</p>';
    	} ?>

    How can I write the code so that it will only echo the above code if the user selected any checkbox data?

    The problem I’m having with the radio buttons is a little different. It just outputs either “1” or “2” depending on if the user selected “yes” or “no” radio in the back end. When creating the custom meta field, I even tried changing the values that showed either 1 or 2, to the actual words “yes” and “no”, but it still shows 1 or 2 on the front end. Here’s my code for that:

    <?php if (!((get_post_meta($post->ID, 'wpcf-foreclosure', TRUE))=='')) {
    	echo '<p><strong>Foreclosure: </strong>'.get_post_meta($post->ID,'wpcf-forecosure',TRUE).'</p>';
    	} ?>

    Any ideas on either of these two issues?


Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi Matt,

    To debugging the issue please let me know which WordPress hook you are using for achieving these conditions.

    Hope you are using WordPress 3.5.1 and Types 1.2.1.

    [ Signature moderated. ]


    What do you mean by what hook I am using? I’m not much of a developer, so I apologize for this. I am using the most recent versions of WordPress and the Types plugin.

    Hi Mat,

    I mean where you have put the following code and how you apply check boxes condition(On select).
    <?php if (!((get_post_meta($post->ID, ‘wpcf-exterior-types’, TRUE))==”)) {
    echo ‘<p>Exterior Types: ‘.get_post_meta($post->ID,’wpcf-exterior-types’,TRUE).'</p>’;
    } ?>

    [ Signature moderated. ]

    Hey Matt – if those are actual copy/paste of code, the second example has foreclosure misspelled in the second reference. Don’t know why the statement is failing but that might be something…

    Hi Mat,

    Any Updates.

    [ Signature moderated. ]

    Is there a way to have a conditional field (a text field) that is triggered based when a specified radio button within in a radio/select group is selected?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Conditional w/ radio and checkboxes’ is closed to new replies.
Skip to toolbar