Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have created a custom post type for a property rental site created with WordPress. In it I want to have the input section as checkboxes:

image one

and get the output like this:

image two

share|improve this question
    
use this plugin and enjoy its features, your answer is in the first page of its website. :) Advanced Custom Fields –  Saeed Alipoor Dec 23 '12 at 13:25
add comment

2 Answers

up vote 1 down vote accepted

You can do this by custom meta, all you have to do create custom metabox and the your checkboxes on it, the easiest way to create custom metabox is

1). Download WP Alchemy Metabox Class from here

2). Palce 'wpalchemy' folder inside of your theme folder

in your function.php file

include_once WP_CONTENT_DIR . '/themes/yourtheme/wpalchemy/MetaBox.php';

3). after that, create two php files by following names 'my-special-feature-meta.php' , 'my-special-feature-spec.php' (you can name your php files whatever you want).

in your 'my-special-feature-spec.php' file

<?php
global my_special_features; 
$my_special_features = new WPAlchemy_MetaBox(array
(
    'id' => '_my_special_features',
    'title' => 'Special Features',
    'template' => get_stylesheet_directory() . 'my-special-feature-meta.php',
    'types' => array('page','post','your_custom_post')
));

/* eof */

and your 'my-special-feature-meta.php' file

Group checkbox test #1

<?php 
 global $my_special_features;
 $items = array('internet', 'laundry', 'garage', 'tv'); 
?>

    <?php while ($my_special_features->have_fields('cb_ex', count($items))): ?>

        <?php $item = $items[$mb->get_the_index()]; ?>

        <input type="checkbox" name="<?php $my_special_features ->the_name(); ?>" value="<?php echo $item; ?>"<?php $my_special_features ->the_checkbox_state($item); ?>/> <?php echo $item; ?><br/>

    <?php endwhile; ?>

okay you have created your checkbox lists in your custom post type, now you have to display the meta results on your front end, to do that, create php function in your functions.php file

function display_special_fetures(){
    global $my_special_features; 
    $myresults = $my_special_features->the_meta();
    if(!empty($myresults)){
     foreach($myresults){
        echo '<img src="'get_stylesheet_directory().'/'.$myresults['cb_ex'].'">';
      }
    }
}

finally place this function inside your loop or single.

share|improve this answer
add comment

You can use the following plugin: http://wordpress.org/extend/plugins/custom-field-suite/

After that, in your template file, just use plugin's API:

<?php if( $cfs->get('field_name') ): ?>
<img src="blank.gif" class="sprite icon" />
<?php endif; ?>

Plugin Documentation: http://uproot.us/projects/cfs/documentation/

Of course, you can use Wordpress built-in functionality, just add your custom field on post edit screen, then use get_post_meta() to get custom field value.

share|improve this answer
    
First of all tnx, Second Let me try this. :) –  irshadav Dec 18 '12 at 12:02
    
Still it is not clear for me, so let me ask again this way I have the custom post type field check boxes named []Internet []TV []Recreation –  irshadav Dec 20 '12 at 2:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.