0

how do you display the latest authors blog post?

I have the below code:

<?php
$author = get_the_author();
$args = array( 'numberposts' => '1', 'author'=>$author );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
    echo '<li><a href="' . get_permalink($recent["ID"]) . '">' .   $recent["post_title"].'</a> </li> ';
}
?>

However the above code display the most recent post for all users instead of a specific user.

1
  • On which page is this Commented Mar 5, 2015 at 4:15

1 Answer 1

0

Please Try This To Get Post in DESC order

$args = array(
    'orderby' => 'title',
    'order'   => 'DESC',
    'author' =>'authorName',
);
$query = new WP_Query( $args );

// The Loop
if ( $query ->have_posts() ) {
    echo '<ul>';
    while ( $query ->have_posts() ) {
        $query ->the_post();
        echo '<li>' . get_the_title() . '</li>';
    }
    echo '</ul>';
} else {
    // no posts found
}
/* Restore original Post Data */
wp_reset_postdata();

Please Check This Link

I hope this will help you. have a good day :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.