WordPress.org

Ready to get started?Download WordPress

Forums

Types - Custom Fields and Custom Post Types Management
[resolved] Checkbox HTML Output (4 posts)

  1. Jay Hoffmann
    Member
    Posted 1 year ago #

    I am trying to output different html based on if a checkbox is selected or not. Basically, this is so a different class is assigned to the div tag. Right now I have:

    <?php echo(types_render_field("inset", array("checked_html"=>base64_encode('<div class="infoBlock">'),"unchecked_html"=>base64_encode('<div class="infoBlockgreen">')))); ?>

    but this is outputting nothing at all. What am I doing wrong?

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

  2. Jay Hoffmann
    Member
    Posted 1 year ago #

    Wasn't able to figure out how use the Types API to do this so I just set up a conditional statement for the custom field value:

    <?php $inset=get_post_meta($post->ID, 'wpcf-inset', true); ?>
    
    <?php if($inset == "1") { ?>
        <div class="infoBlockgreen">
    <?php } else { ?>
    <div class="infoBlock">
    <?php } ?>

    Pretty simple, the custom field key will be the "wpcf-" prefix plus whatever the slug of the Types field you set up is.

  3. AmirHelzer
    Member
    Plugin Author

    Posted 1 year ago #

    To debug this, I would enable debug mode (see PHP issues) and also try to use 'raw'=>'true', just to see if the field name is correct (which it should).

    Anyway, I'll mark this as resolved, as you have a different solution. If you want to continue debugging the intended use, let me know.

  4. bryomedia
    Member
    Posted 1 year ago #

    Please put the recommended solution for others to see. Thank you.

    Great plugin, but documentation isn't for the beginner type.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic