• I have seen ways to list the latest authors on a sites index page but what i would like is to display the latest two authors with their image and meta description on the homepage.

    You can see the ‘Latest contributors’ (our term of authors) div I am trying to make dynamic here: https://verbsandpixels.com/

    Thanks for your help,

Viewing 3 replies - 1 through 3 (of 3 total)
  • @thetattoedbook, So you first you need to get the id’s of the authors of the latest two posts…

    <?php
    	$args = array(
    	    'numberposts' => 2,
    	    'orderby' => 'post_date',
    	    'order' => 'DESC',
    	    'post_type' => 'post',
    	);
    ?>
    
    <?php $latest_two_posts = wp_get_recent_posts( $args ); ?>

    If you var_dump(); the $latest_two_posts variable then you can see what it returns but what we want are the author ids.

    Next we now need to loop through these two post info arrays and use the author’s id to find their respective meta data so…

    <?php foreach ($latest_two_posts as $post): ?>
    
    		<?php echo get_the_author_meta( 'display_name', $post['post_author'] ); //Name ?>
    		<?php echo get_the_author_meta( 'description', $post['post_author'] ); //Name ?>
    
    	<?php endforeach ?>

    So we use get_author_meta() with the author’s id to find the relevant info. I have only done two examples but check this link https://codex.www.ads-software.com/Function_Reference/get_the_author_meta to see all of the possible author meta data you can get.

    Hope this helps

    Thread Starter thetattoedbook

    (@thetattoedbook)

    That works perfectly. Exactly what we wanted. Thanks so much,

    @ajshortt

    Nice.
    thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do i display latest author details on my homepage?’ is closed to new replies.