I have coded as below for Recent post by same author. Code is working fine and giving me recent post by same author, but it show more than one post (but I need 1 post to show)
<div class="popular-post-wrapper">
<h4 class="blog-post-sub-title">Most Recent</h4>
<div class="col-md-3 popular-post-thumbnail">
<?php
$query_posts=array(
'orderby' => 'display_name',
'order' => 'ASC',
'who' => 'authors',
'posts_per_page' => '1' );
if (have_posts()) : while (have_posts()) : the_post();
?>
<?php //if ( has_post_thumbnail() ) : ?>
<a href="<?php //the_permalink(); ?>" title="<?php //the_title_attribute(); ?>">
<?php //the_post_thumbnail(); ?>
</a>
<?php //endif; ?>
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail();
} else { ?>
<img src="https://kubalubra.is/wp-content/uploads/2017/11/default-thumbnail.jpg" alt="<?php the_title(); ?>" />
<?php } ?>
</div>
<div class="col-md-9 post-title-wrapper">
<h3> <a href="<?php the_permalink(); ?>">
<?php the_title();?>
</a></h3>
</div>
<?php
endwhile; endif;
wp_reset_query();
?>
</div>
Aucun commentaire:
Enregistrer un commentaire