Php 在wordpress模板中显示所有用户/作者
我正在尝试使用高级自定义字段在自定义页面模板中显示我的所有作者/用户。我使用以下代码显示他们的个人资料照片,这些照片是从名为Php 在wordpress模板中显示所有用户/作者,php,wordpress,advanced-custom-fields,user-profile,Php,Wordpress,Advanced Custom Fields,User Profile,我正在尝试使用高级自定义字段在自定义页面模板中显示我的所有作者/用户。我使用以下代码显示他们的个人资料照片,这些照片是从名为author\u header的acf图像字段中抓取的。我按以下顺序将用户放入无序列表中 <div class="author"> <ul> <li> <?php $publisher_photo = get_the_author_meta('author_header'); $image_sr
author\u header
的acf图像字段中抓取的。我按以下顺序将用户放入无序列表中
<div class="author">
<ul>
<li>
<?php
$publisher_photo = get_the_author_meta('author_header');
$image_src = wp_get_attachment_image_src($publisher_photo);
echo '<img src="'. $image_src[0] .'" />';
?>
</li>
</ul>
</div>
<h2 class="authorName">[ <?php echo $user->display_name; ?> ]</h2>
我确实让他们的名字正确地显示在无序列表中,如下所示
<div class="author">
<ul>
<li>
<?php
$publisher_photo = get_the_author_meta('author_header');
$image_src = wp_get_attachment_image_src($publisher_photo);
echo '<img src="'. $image_src[0] .'" />';
?>
</li>
</ul>
</div>
<h2 class="authorName">[ <?php echo $user->display_name; ?> ]</h2>
[]
您应该在获取作者元数据中添加用户ID,如下所示:
$user_id = $user->ID;
$publisher_photo = get_the_author_meta('author_header', $user_id);
请确保将此代码添加到循环中,以便每次不同的用户的用户id都不同
问候,,
斯坦尼米尔