I have an author list that I include on every page template. This author list shows the authors details and photo. I also show the author images on many different place on the different page templates. This use to work well until I changed the way I get the author details.
I reverted back to the old method I used that worked but my author images just doesn't show up. It's still works in the author list but the image on the template pages gives me the error variable currentauth doesn't exist.
What am I missing?
Debug Info:
NOTICE: wp-content/themes/ewarch/single-project_post.php:81 - Undefined variable: curauth
NOTICE: wp-content/themes/ewarch/single-project_post.php:81 - Trying to get property of non-object
NOTICE: wp-content/themes/ewarch/single-project_post.php:82 - Undefined variable: curauth
NOTICE: wp-content/themes/ewarch/single-project_post.php:82 - Trying to get property of non-object –
AUTHOR_LIST:
<div class="author-list">
<div class="author-list-inner">
<?php
// Get the authors from the database ordered randomly
global $wpdb;
$auth_query = "SELECT ID, user_nicename from $wpdb->users WHERE ID != '1' ORDER BY 'ASC' LIMIT 20";
$author_ids = $wpdb->get_results($auth_query);
// Loop through each author
foreach($author_ids as $author) :
// Get user data
$curauth = get_userdata($author->ID);
// Get link to author page
$user_link = get_author_posts_url($curauth->ID);
$post_link = get_permalink($curauth->ID);
// Set default avatar (values = default, wavatar, identicon, monsterid)
$main_profile = get_the_author_meta('mainProfile', $curauth->ID);
$hover_profile = get_the_author_meta('hoverProfile', $curauth->ID);
$award_profile = get_the_author_meta('awardProfile', $curauth->ID);
?>
<div class="da-author">
<div class="original-image">
<img src="<?php echo $main_profile; ?>" alt="<?php echo $curauth->display_name; ?>">
</div>
<div class="hover-image">
<a href="<?php echo $user_link; ?>">
<img src="<?php echo $hover_profile; ?>">
</a>
</div>
</div>
<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
</div>
PAGE_TEMPLATE:
<div id="projects-single" class="<?php if (get_field('awards')): ?> award-winner <?php endif; ?> js-height">
<div class="author-container hide-for-medium-down start-closed">
<?php get_template_part( 'author_list' ); ?>
</div>
<div class="small-12 large-12 columns">
<?php while(have_posts()): the_post(); ?>
<div class="large-set">
<header>
<h2><?php the_title(); ?></h2>
<?php if (get_field('awards')): ?>
<h3><?php the_field('award_title'); ?></h3>
<?php endif; ?>
<div id="author-meta" class="show-for-small-only">
<p><?php the_author_posts_link(); ?> was involved with <?php the_title(); ?></p>
</div>
</header>
<div class="show-for-small-only">
<hr>
</div>
<div class="entry-content">
<?php the_content(); ?>
</div>
<div class="author-set hide-for-small">
<div class="author-project-image">
<img src="<?php echo get_the_author_meta('mainProfile', $curauth->ID); ?>" class="no-award">
<img src="<?php echo get_the_author_meta('awardProfile', $curauth->ID); ?>" class="award">
</div>
<div class="author-project-blurb">
<h3><?php the_author_posts_link(); ?></h3>
<p>I was part of the design team on the <?php the_title(); ?> project.</p>
</div>
</div>
</div>
</article>
<?php endwhile; ?>
</div>
</div>
THIS IS THE PART WHERE I SHOW THE IMAGES:
<img src="<?php echo get_the_author_meta('mainProfile', $curauth->ID); ?>" class="no-award">
<img src="<?php echo get_the_author_meta('awardProfile', $curauth->ID); ?>" class="award">