This is the current setup I have:
I am able to access individually each person (entries from the custom post type People). And what I would like to do is from that view, be able to also have access to all blog post entries and filter by the relationship field to display only the blog posts written by that person.
Any idea on how to do this with Twig? Once I am on the People "context" I can't find the way to get access to the blog posts "context" as well.
Usually you would need to create a custom query for this which you would add in single-people.php :
// an author's blog articles
$args = array(
'post_type' => 'post',
'posts_per_page' => '9',
'orderby' => 'date',
'order'=> 'DESC',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'people', // name of custom field
'value' => '"' . get_the_ID() . '"',
'compare' => 'LIKE'
)
)
);
$context['blogs'] = Timber::get_posts( $args );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.