How can I add a custom field to an array? 更为复杂的是,自定义字段位于作者页面上,而不是普通帖子上。它是通过高级自定义字段添加的。通常,该字段值将使用<?php the_field(author_status); ?>
.
这是我现在正在使用的完整代码。
<?php
//displays all users with their avatar and their posts (titles)
$blogusers = get_users_of_blog();
if ($blogusers) {
foreach ($blogusers as $bloguser) {
echo \'<div class="content-slider-body">\';
$user = get_userdata($bloguser->user_id);
echo \'<div class="grid col-140">\' . get_avatar( $user->ID, 128 ) . \'</div>\';
$args=array(
\'author\' => $user->ID,
\'post_type\' => \'post\',
\'post_status\' => \'publish\',
\'posts_per_page\' => 1,
\'caller_get_posts\'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
//echo \'List of Posts for \' . user->user_firstname . \' \' . $user->user_lastname;
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<div class="grid col-460 fit"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<!--post-meta-->
<div class="post-data"><span class="date"><?php the_time(\'F jS, Y\') ?></span> by <?php the_author_posts_link(); ?>
<?php if ( comments_open() ) : ?>
<span class="comments-link">
<?php comments_popup_link(__(\'Leave a Comment ↓\', \'responsive\'), __(\'1 Comment ↓\', \'responsive\'), __(\'% Comments ↓\', \'responsive\')); ?>
</span>
<?php endif; ?>
</div>
<br /><?php the_excerpt(); ?></div>
<?php echo \'<span class="rsTmb">\' . $user->user_firstname . \' \' . $user->user_lastname . \'</span></div>\'; ?>
<?php
endwhile;
}
wp_reset_query(); // Restore global post data stomped by the_post().
}
}
?>
天哪,我成功了!将其放置在可重复区域中我需要的位置:
<?php the_author_meta( \'author_status\', $user->ID ); ?>