Hi, Metabox.
I created a custom field for related posts via post advanced select but I having a problem showing the author's name and comment counts inside single blog post.
Want to display:
https://markuphero.com/share/dM0giAmjeFkEFdckpu2x
<?php
add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
function your_prefix_function_name( $meta_boxes ) {
$prefix = '';
$meta_boxes[] = [
'title' => __( 'Related Post', 'your-text-domain' ),
'id' => 'related-post',
'fields' => [
[
'name' => __( 'Post', 'your-text-domain' ),
'id' => $prefix . 'post_related',
'type' => 'post',
'post_type' => ['post'],
'field_type' => 'select_advanced',
'multiple' => true,
],
],
];
return $meta_boxes;
}
<div class="post-related">
{% for post in query.posts %}
{% for item in post.post_related %}
<div class="p2-post-related__card">
<h2 class="p2-post-related__header">
<h3 class="p2-post-related__category">{{ mb.get_the_term_list( item.ID, 'category', '', ', ' ) }}</h3>
<a href="{{ item.url }}" class="p2-post-related__title">{{ item.title }}</a>
</h2>
<div class="p2-post-related__meta">
<div class="p2-post-related_author_name">By <a href="#">Julia James</a></div>
<div class="p2-post-related_details"><span>{{ item.date | date( 'F j, Y' ) }}</span> · <span>6 comments</span></div>
</div>
<div>
<img src="{{ item.thumbnail.full.url }}" width="{{ item.thumbnail.full.width }}" height="{{ item.thumbnail.full.height }}" alt="{{ item.thumbnail.full.alt }}" class="p2-post-related__thumbnail">
</div>
</div>
{% endfor %}
{% endfor %}
</div>
<!-- post-related -->
Thank you.