• 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.