WordPress.org

Ready to get started?Download WordPress

Forums

Types - Custom Fields and Custom Post Types Management
Conditional w/ radio and checkboxes (7 posts)

  1. Matt Rittman
    Member
    Posted 1 year ago #

    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?

    http://wordpress.org/extend/plugins/types/

  2. mbigul
    Member
    Plugin Author

    Posted 1 year ago #

    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. ]

  3. Matt Rittman
    Member
    Posted 1 year ago #

    Bigul,

    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.

  4. mbigul
    Member
    Plugin Author

    Posted 1 year ago #

    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. ]

  5. NorCalAl
    Member
    Posted 1 year ago #

    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...

  6. mbigul
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Mat,

    Any Updates.

    [ Signature moderated. ]

  7. WomperScomper
    Member
    Posted 10 months ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic