I am archiving all the posts from particular custom post type on a page using the following code.
<?php
/*
Template Name: List-all-shorts
*/
?>
<?php get_header(); ?>
<div class="row">
<div class="all-shorts-container">
<h2>Shorts</h2>
<?php
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$author = the_author();
$custom_args = array(
'post_type' => 'news',
'posts_per_page' => 10,
'paged' => $paged,
'author' => $author
);
$custom_query = new WP_Query( $custom_args ); ?>
<?php if ( $custom_query->have_posts() ) : ?>
<!-- the loop -->
<?php while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?>
<div class="single-shorts-container">
<article class="short-box">
<div class="short-content">
<div class="short-meta-box">
<div class="short-author-meta-img"> <?php the_author_image();
?>
</div>
<p><?php the_content(); ?></p>
</div>
</article>
<footer class="short-rating-footer">
<?php if(function_exists('the_ratings')) { the_ratings(); } ?>
</footer>
</div>
<?php endwhile; ?>
<!-- end of the loop -->
<!-- pagination here -->
<!-- pagination here -->
<?php
if (function_exists(custom_pagination)) {
custom_pagination($custom_query->max_num_pages,"",$paged);
}
?>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
</div>
</div>
<?php get_footer(); ?>
The above code displays all the posts as I wanted. I am trying to show author image of all the individual posts accordingly. I tried using
<?php the_author(); ?> and <?php echo get_avatar( get_the_author_email(), '32' ); ?>
and many other things. But I am getting the image of the author of the page. I am quite not sure where I went wrong.
Also, I am able to get the author name and author profile link for the posts. Any help would be highly appreciated.