Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Printing an Array as an Unordered List

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #37257
    realph
    Participant

    I’m using Bill Erickson Custom Meta Boxes and Fields for WordPress and was wondering how I’d go about printing an array of checkboxes as an unordered list.

    This is what I’ve got in my theme’s functions.php file:

    array(
    'name' => 'Other Features',
    'desc' => 'field description (optional)',
    'id' => $prefix . 'other_features',
    'type' => 'multicheck',
    'options' => array(
    'language' => 'English Speaking',
    'furniture' => 'Modern & Classic Furniture',
    'fridge' => 'Fridge/Freezer',
    'stove' => 'Wood Burning Stove',
    'oven' => 'Electric Oven',
    'internet' => 'Free Wi-Fi',
    'tv' => 'Television/DVD Player',
    'plugs' => 'UK Power Plugs',
    )
    ),

    And this is how it appears in my Add/Edit page panel:


    What I’d like to know how to do is print only the selected checkboxes as an unordered list with their ID, like so:


    • English Speaking

    • Modern & Classic Furniture

    • Wood Burning Stove

    • Electric Oven

    • Free Wi-Fi

    • Television/DVD Player

    Any help at all to point me in the right direction would be much appreciated. Thanks in advance.

    #99925
    realph
    Participant

    Here’s what I ended up using, courtesy of Bill Erickson himself:

    
    global $post;
    $other_features = get_post_meta( $post->ID, 'other_features' );
    echo '
      ';
      foreach( $other_features as $id => $value )
      echo '
    • ' . $value . '
    • ';
      echo '
    ';
    ?>
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.