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 badge1 Answer
Reset to default 0You should uncomment first line and add author query var.
$wp_query->query_vars["author_name"] = "John";