Title: Echo custom post field in shortcode
Last modified: August 31, 2016

---

# Echo custom post field in shortcode

 *  [Joren Wouters](https://wordpress.org/support/users/jorenman/)
 * (@jorenman)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/echo-custom-post-field-in-shortcode/)
 * Hello everyone,
 * I have made a custom post type, which is called **condoleance**.
    Also, I made
   a custom field for that custom post field, named **date_of_birth**.
 * Now, I want to display all the condoleance posts in a table.
    That is going really
   well, but WordPress won’t echo the date_of_birth of every post.
 * Does anyone know how to do that?
    This is my code:
 *     ```
       $query = new WP_Query( $args );
               if( $query->have_posts() ){
                   $string .= '<table class="condoleance">
       							<tr>
       								<th>
       									<strong>Naam</strong>
       								</th>
       								<th>
       									<strong>Overlijdensdatum</strong>
       								</th>
       							</tr>
       						';
                    while ( $query->have_posts() ) : $query->the_post();
                       $string .= '<tr>
       								<td class="condo-info">
       									<a href=" ' . get_the_permalink() . ' ">' . $image . '
       									' . get_the_title() . '</a>
       								</td>
       								<td class="condo-overlijden">
       									' . get_post_meta($wp_query->post->ID, 'date_of_birth', true) . '
       								</td>
       							</tr>	';
       			endwhile;
                   $string .= '</table>';
       		}
               wp_reset_query();
               return $string;
       ```
   
 * Regards,
    Joren

The topic ‘Echo custom post field in shortcode’ is closed to new replies.

## Tags

 * [custom post field](https://wordpress.org/support/topic-tag/custom-post-field/)
 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 0 replies
 * 1 participant
 * Last reply from: [Joren Wouters](https://wordpress.org/support/users/jorenman/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/echo-custom-post-field-in-shortcode/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
