最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Display post by Random Authors on Page Refresh

programmeradmin1浏览0评论

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()?>
发布评论

评论列表(0)

  1. 暂无评论