Display comma separated custom field values
-
I’m using this code to get custom field values from subpages:
<?php $args = array( 'post_type' => 'page', 'post_status' => 'publish', 'post_parent' => $post->ID ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <p><?php echo get_post_meta($post->ID, 'Email', true); ?></p> <?php endwhile; } wp_reset_query(); ?>
This way I got this output:
<p>email 1</p> <p>email 2</p> <p>email 3</p> <p>email 4</p>
I would like to know how to get a comma separated output like this one:
<p>email 1,email 2,email 3,email 4</p>
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Display comma separated custom field values’ is closed to new replies.