• Resolved Mantas47

    (@mantas47)


    I use this your code (https://www.ads-software.com/support/topic/custom-field-output-in-grid-display-listings/)

    // get custom fields
    $args = array(
        'post_type' => 'acadp_fields',
        'tax_query' => array(
            array(
    	    'taxonomy' => 'acadp_categories',
    	    'field'    => 'term_id',
    	    'terms'    => $category[0]->term_id,
           ),
        ),
        'meta_key'  => 'order',
        'order_by'  => 'meta_value_num',
        'order'     => 'ASC',
    );
    
    $fields = get_posts( $args );
    ?>
    
    <?php if( count( $fields ) ) : ?>
        <ul class="list-group acadp-margin-bottom">
            <?php foreach( $fields as $field )  : ?>
                <?php if( $value = get_post_meta( $post->ID, $field->ID, true ) ) : ?>
        	        <li class="list-group-item acadp-no-margin-left">
                        <span class="text-primary"><?php echo $field->post_title; ?></span> :
    		    <span class="text-muted"><?php echo $value; ?></span>
                   </li>
               <?php endif; ?>
           <?php endforeach; ?>
        </ul>
    <?php endif; ?>

    How to separate commas custom fields ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author pluginsware

    (@pluginsware)

    Sorry, your question is not clear. I assume you’re using the checkbox field type and looking to separate the values of this field type using comma(,). Am I correct?

    Then, find the following line,
    <span class="text-muted"><?php echo $value; ?></span>

    and Change it as,

    <?php
      $type = get_post_meta( $field->ID, 'type', true );
      if( 'checkbox' == $type ) $value = str_replace( "\n", ', ', $value );
    ?>
    <span class="text-muted"><?php echo $value; ?></span>

    Save the changes and try now.

    • This reply was modified 7 years, 3 months ago by pluginsware.
    • This reply was modified 7 years, 3 months ago by pluginsware.
    Thread Starter Mantas47

    (@mantas47)

    Yes. Thanks you. ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom fields separate commas’ is closed to new replies.