77 lines
No EOL
1.8 KiB
PHP
77 lines
No EOL
1.8 KiB
PHP
<?php
|
|
/**
|
|
* Template Name: Directory
|
|
*
|
|
* The template for displaying all profiles in a directory
|
|
*
|
|
* @subpackage wasmo
|
|
* @since 1.0.0
|
|
*/
|
|
|
|
get_header();
|
|
?>
|
|
|
|
<section id="primary" class="content-area">
|
|
<main id="main" class="site-main">
|
|
|
|
<?php
|
|
|
|
/* Start the Loop */
|
|
while ( have_posts() ) :
|
|
the_post();
|
|
|
|
get_template_part( 'template-parts/content/content', 'page' );
|
|
|
|
endwhile; // End of the loop.
|
|
?>
|
|
|
|
<?php
|
|
// Directory
|
|
|
|
/* Start the Loop */
|
|
$args = array(
|
|
'orderby' => 'ID',
|
|
'order' => 'ASC',
|
|
'fields' => 'all',
|
|
);
|
|
$users = get_users( $args );
|
|
|
|
?>
|
|
<article class="entry the-directory">
|
|
<div class="entry-content">
|
|
<div class="directory">
|
|
|
|
<?php
|
|
// Array of WP_User objects.
|
|
foreach ( $users as $user ) {
|
|
$userid = $user->ID;
|
|
|
|
// only add to directory if user includes themself
|
|
// true = public
|
|
// private = only to a logged in user
|
|
if ( 'true' === get_field( 'in_directory', 'user_' . $userid ) ||
|
|
'private' === get_field( 'in_directory', 'user_' . $userid ) && is_user_logged_in() ) {
|
|
$userimg = get_field( 'photo', 'user_' . $userid );
|
|
$username = esc_html( $user->nickname );
|
|
?>
|
|
<a class="person person-<?php echo $userid; ?>" href="<?php echo get_author_posts_url( $userid ); ?>">
|
|
<span class="directory-img"><?php
|
|
if ( $userimg ) {
|
|
echo wp_get_attachment_image( $userimg, 'medium' );
|
|
} else {
|
|
echo '<img src="' . get_stylesheet_directory_uri() . '/img/default.svg">';
|
|
}
|
|
?></span>
|
|
<span class="directory-name"><?php echo $username; ?></span>
|
|
</a>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
</div></div>
|
|
</article>
|
|
</main><!-- #main -->
|
|
</section><!-- #primary -->
|
|
|
|
<?php
|
|
get_footer();
|