First of all, I have a custom function in functions.php
that gets some author information. This works on great on single posts with a single author.
<?php function the_author_box() { ?>
<div class="widget about-the-author-widget">
<h3 class="widget-title">Over de auteur</h3>
<div class="author-header clear">
<div class="author-avatar-wrap"><?php echo get_avatar(get_the_author_meta( 'ID' )); ?></div>
<h4 class="author-name"><?php the_author_meta('display_name'); ?></h4>
</div>
<div class="author-description"><p><?php the_author_meta('description'); ?></p></div>
<ul class="author-meta">
<?php if ( get_the_author_meta( 'url' ) ) { ?>
<li class="url">
<a href="<?php the_author_meta( 'url' ); ?>" title="De website van <?php the_author_meta( 'display_name' ); ?>">Website</a>
</li>
<?php // a lot more metas ?>
</ul>
</div>
<?php
} ?>
But now I'm designing a custom page template to display the 'the_author_box' for every user who is either a contributor or an administrator. All on the same page.
I figured I could get the users by doing so (borrowed from stackexchange). Build a new function:
function get_clients() {
$users = array();
$roles = array('author', 'contributor', 'administrator');
foreach ($roles as $role) :
$users_query = new WP_User_Query( array(
'fields' => 'all_with_meta',
'role' => $role,
'orderby' => 'display_name'
) );
$results = $users_query->get_results();
if ($results) $users = array_merge($users, $results);
endforeach;
return $users;
}
Call the users, and execute the function for every user:
<?php
$users_array = get_clients();
foreach ($users_array as $user) {
$user->the_author_box();
?>
But that doesn't work. I am guessing because it's still 'the author meta' that's called, and not the user's meta.
How can I call a function for $user->function()
. In other words, how can I get meta information from that user?