0

how can U get latest posts from a specific category and post them with the picture of the author. All authors are signed as an author on WordPress and they all have profile picture. Actually it will stand for columns side like this enter image description hereand the system must get latest 1 first then the second and third goes like this...

0

You could try something like this:

<?php
$args = array( 'category' => 12, 'post_type' =>  'post' ); 
$postslist = get_posts( $args );    
foreach ($postslist as $post) :  
setup_postdata($post); 
?>  
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
<h4><?php the_author();?></h4> 
<?php 
the_excerpt(); 
echo get_avatar(get_the_author_meta());     
endforeach; 
?> 

In the example the category id is set to 12 - just replace it with the id of the category you want to use.

More info:
How to loop through posts: https://developer.wordpress.org/reference/functions/get_posts/#user-contributed-notes
How to get the author name: https://codex.wordpress.org/Function_Reference/the_author
How to get the author image: https://codex.wordpress.org/Function_Reference/get_avatar

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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