Display custom field with related posts
-
I can successfully display these related posts with the below code, however, I would like to display a custom field (which is actually the subheading) below the title, currently it is set to show the excerpt.
I tried adding this:
$related_post->get_post_meta($related_post->ID, "_subheading", true)
instead of the excerpt but it didn’t work.Any tips would be really helpful?
$related_posts = MRP_get_related_posts( $post->ID ); if(!empty($related_posts)) { echo '<aside id="categories-4" class="widget widget_related"> <h4 class="widget-title">Related Posts</h4>'; foreach($related_posts as $key => $value) { $related_post = get_post($key); $related_thumb = get_the_post_thumbnail($related_post->ID, $options['popular_post']); if (!empty($related_thumb)) { echo "<div class='wid clearfix'><span class='wid-thumb' style='width:15%'>".get_the_post_thumbnail($related_post->ID, $options['popular_post'])."</span>"; } else { echo "<div class='wid clearfix'><span class='wid-thumb' style='width:15%'><img src='".get_template_directory_uri()."/inc/img/blank.jpg'></span>";} echo "<span class='wid-text'>".$related_post->post_title."</span>"; echo "<div class='entry-meta'><span class='wid-text'>".$related_post->post_excerpt."</span></div></div>"; } echo '</aside>';
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Display custom field with related posts’ is closed to new replies.