Hi Metabox,
Can you let me know why my code is not working? The other post details are showing except for this author name. I tried the get_the_author_meta
but the output is incorrect. Any help?
Views
<div class="p2-post-related">
{% for item in post.related_post_single_product %}
<div class="p2-post-related__card p2-post-related__card--centered">
<img src="{{ item.thumbnail.full.url }}" width="{{ item.thumbnail.full.width }}" height="{{ item.thumbnail.full.height }}" alt="{{ item.thumbnail.full.alt }}">
<div class="p2-post-related__wrapper">
<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="#">{{ mb.get_the_author_meta('nickname', author.ID) }} {{ mb.get_the_author_meta('last_name', author.ID) }}</a></div>
</div>
</div>
</div>
<!-- p2-post-related__card -->
{% endfor %}
</div>
The custom field
<?php
add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
function your_prefix_function_name( $meta_boxes ) {
$prefix = '';
$meta_boxes[] = [
'title' => __( 'Add Related Post', 'your-text-domain' ),
'id' => 'related-post-single-product',
'post_types' => ['product'],
'fields' => [
[
'name' => __( 'Post', 'your-text-domain' ),
'id' => $prefix . 'related_post_single_product',
'type' => 'post',
'post_type' => ['post'],
'field_type' => 'select_advanced',
'multiple' => true,
],
],
];
return $meta_boxes;
}