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

php - Show all posts by author

programmeradmin4浏览0评论

I used to have a page on my site where it would show all posts by a user and it worked. This was the code it was using:

    <?php
    //$wp_query = new WP_Query( array( 'post_per_page' => 12 ));
    $wp_query->query_vars["posts_per_page"] = 24;
    $wp_query->query_vars["orderby"] = 'title';
    $wp_query->query_vars["order"] = 'ASC';
    $wp_query->get_posts();
    ?>

    <?php if ( have_posts() ) : ?>

Nothing has changed but it recently stopped showing results. Any ideas what has gone wrong?

I used to have a page on my site where it would show all posts by a user and it worked. This was the code it was using:

    <?php
    //$wp_query = new WP_Query( array( 'post_per_page' => 12 ));
    $wp_query->query_vars["posts_per_page"] = 24;
    $wp_query->query_vars["orderby"] = 'title';
    $wp_query->query_vars["order"] = 'ASC';
    $wp_query->get_posts();
    ?>

    <?php if ( have_posts() ) : ?>

Nothing has changed but it recently stopped showing results. Any ideas what has gone wrong?

Share Improve this question asked Feb 24, 2022 at 18:11 David JonesDavid Jones 111 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

You should uncomment first line and add author query var.

 $wp_query->query_vars["author_name"] = "John";

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论