Forums

[Plugin: Custom Field Template ] Display all values of (4 posts)

  1. Norke
    Member
    Posted 12 months ago #

    Hi chaps,

    In Custom Field Template I have this set up:

    [Colors]
    type = checkbox
    value = Blue # Yellow # Black # White

    A post can have multiple colors, so how can I display those?

    For instance: Color: Blue, Black, White

    Thx ahead guys :)

  2. Alexey
    Member
    Posted 11 months ago #

    You should edit your template.
    Add some element, div for example, in template. Assign background-color for in with custom field value.

    Insert this code in your theme
    <div style="width:50px; height:50px; background-color: [INSERT HERE cft code];"></div>

  3. proximity2008
    Member
    Posted 11 months ago #

    Further to Alexey's solution:

    <?php
    $colour = 'White'; // set a default
    $colour =  get_post_meta( $post->ID, 'Colors', true ); ?>
    <div style="width:50px; height:50px; background-color:<?php echo $colour ?>"></div>
  4. Zeb
    Member
    Posted 9 months ago #

    Thanks for sharing this.

    How is it possible to get the title as well? For example, in the above mentioned example, displaying the following (if the colors are selected):

    Colors: Blue, Yellow, Black, White

Reply

You must log in to post.

About this Topic