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">
    <div id="post_author">
        <?php author_post(7,'rand', 'post_type', 'random_author_id'); ?>

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()?>


>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/display-post-by-random-authors-on-page-refresh/">

Display post by Random Authors on Page Refresh</a>
, mems 9 months 0 Answers 33 views 0

Leave an answer