我通过ACF在博客帖子和自定义帖子类型之间创建了一种关系,该类型包含员工资料。通过这种关系,我可以显示员工的个人资料的链接,该个人资料是帖子的作者。
我现在想显示员工在其个人资料中创建的帖子列表。我能够找到执行此操作的code。不幸的是,每当我给一个员工分配5个以上的博客帖子时,下一个帖子就不可见。您能否帮助我并调整代码以在新行中显示5个以上的帖子?
<div class="author-content">
<?php
/*
* Query posts for a relationship value.
* This method uses the meta_query LIKE to match the string "123" to the database value a:1:{i:0;s:3:"123";} (serialized array)
*/
$documents = get_posts(array(
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'our_people_author', // name of custom field
'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
'compare' => 'LIKE'
)
)
));
?>
<?php if( $documents ): ?>
<ul class="table-author">
<?php foreach( $documents as $document ): ?>
<li class="singleauth-list">
<a href="<?php echo get_permalink( $document->ID ); ?>"><img src="<?php echo get_the_post_thumbnail_url($document->ID, 'thumbnail');?>" class="people-post-image"></a>
<a href="<?php echo get_permalink( $document->ID ); ?>" class="author-links">
<?php echo get_the_title( $document->ID ); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>