Display post by Random Authors on Page Refresh

I want to display post by random author’s id, like this :

<div class=”css_class”>
<div class=”author_id”>
author_name
</div>
<div id=”post_author”>
<?php author_post(7,’rand’, ‘post_type’, ‘random_author_id’); ?>
</div>
</div>

How I can get random authors and then display 10 post by that author?
also when I refresh the page It should display another author with their posts.

my function to display post :

function author_post($total_post, $orderby, $random_author_id){
global $post;
$original_post = $post;
$args = array(
‘post_type’ => ‘post’,
‘orderby’ => $orderby,
‘posts_per_page’ => $total_post,
‘author’ => $random_author_id
);
$get_posts_query = new WP_Query( $args );
while ( $get_posts_query->have_posts() ) : $get_posts_query->the_post()?>

Read more here:: Display post by Random Authors on Page Refresh

Leave a Reply

Your email address will not be published. Required fields are marked *