• jubbling

    (@jubbling)


    Working a site where they used ONE custom field, multiple times, with different values. Trying to display all of the values comma separated.

    thanks for any help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi Jubblink I am rather novice in WP but some how solved this problem. Do not pretend this is the best solution. First of all we have build in directoryengine custom field like et_phone and these ones added by web master. For example you may add et_phone2, et_phone3 and so on but nice phone will be missed and replace with some ugly text:. So my solution is add multiple et_phone (just add custom field with same name typed by hand not from drop down menu in wp admin setting->custom fields. Fill data. One small trick rest in file that shows phone usually single_place_details.php but there could be others for example in mobile directory, add in header php tag

    $phones = get_post_meta($post->ID, “et_phone”, false);
    Do now worry that $post->ID is not in global or set here it is set in files that includes single_place_details.php.

    Find this one
    <?php if($place->et_phone){ ?>
    <li class=”phone-place”>
    <span itemprop=”telephone” class=”phone-place limit-display” <?php _e(“Phone”, ET_DOMAIN); ?>>
    <i class=”fa fa-phone”></i><?php echo ($place->et_phone) ? $place->et_phone : __( ‘No specify phone’ , ET_DOMAIN );; ?>
    </span>

    <?php } ?>

    and replace with
    <?php if(!empty($phones)):
    foreach($phones as $phone):
    ?>
    <li class=”phone-place”>
    <span itemprop=”telephone” class=”phone-place limit-display” <?php _e(“Phone”, ET_DOMAIN); ?>>
    <i class=”fa fa-phone”></i><?php echo ($phone) ? $phone : __( ‘No specify phone’ , ET_DOMAIN );; ?>
    </span>

    <?php
    endforeach;
    endif;
    ?>

    Thread Starter jubbling

    (@jubbling)

    Thanks for the follow up. Forgot i posted this! Did figure out a work around so we’re ok.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Displaying multiple values for one custom field’ is closed to new replies.