• Hi,
    I’m using the Custom Field Template-plugin. It’s awesome, but I can’t seem to figure out how to display more than one checkbox-item in my page-template.

    When I use the checkbox and I check f.ex two items the plugin adds two custom fields with the same name. and my php-code only call the lowest one. How do i call all values of custom fields with the same name?

    f.ex:

    [my_checkbox]
    label = What fruit?
    type = checkbox
    value = apple # orange # banana # grape

    If I choose “apple” and “orange” and I then call: get_post_meta($post->ID, 'my_checkbox', true)

    it only displays “apple”. How do I display all, and how do I make it like a list?

    http://wordpress.org/extend/plugins/custom-field-template/

Viewing 4 replies - 1 through 4 (of 4 total)
  • If you set false to the third argument, the function returns an array of the custom fields. Please look at the following link:

    http://codex.wordpress.org/Function_Reference/get_post_meta

    I used “Custom Field Template” plugin and I used the checkboxes:

    [example_field]
    type = checkbox
    value = item1 # item2 # item3 # item4
    default = 0

    I get the text “Array” but the description and example of http://codex.wordpress.org/Function_Reference/get_post_meta is very ,very confused and Idn’t understand the solution.

    My code code in sidebar:

    <?php
    global $wp_query;
    global $post_id;
    $post_id = $wp_query->post->ID;

    $example_field = get_post_meta($post_id, ‘example_field’, false);

    if ( get_post_meta($post_id, ‘example_field’, false)){
    echo $example_field;}
    ?>

    In my sidebar display this:

    Array

    I need show like as:

    item1
    item3
    item4

    Excume, Idon’t use I used backticks for the code.

    “Custom Field Template” plugin and I used the checkboxes:

    [example_field]
    type = checkbox
    value = item1 # item2 # item3 # item4
    default = 0

    I get the text “Array” but the description and example of http://codex.wordpress.org/Function_Reference/get_post_meta is very ,very confused and Idn’t understand the solution.

    My code code in sidebar:

    <?php
    global $wp_query;
    global $post_id;
    $post_id = $wp_query->post->ID;
    
    $example_field = get_post_meta($post_id, 'example_field', false);
    
    if ( get_post_meta($post_id, 'example_field', false)){
    echo $example_field;}
    ?>

    In my sidebar display this:

    Array

    I need show like as:

    item1
    item3
    item4

    Solution to the problem:

    <?php
    $Custom_Key = get_post_meta($post_id, 'Custom_Key', false);
    foreach ($Custom_Key as $anything) {echo "<li>".$anything."</li>";}echo "</ul>";
     ?>

    Voila

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Custom Field Template]: Call multiple checkbox-items’ is closed to new replies.