I'm not experienced with the WordPress. My goal is to display all the posts on the page.
I was trying to display posts on a page like so:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
...
<?php endwhile; else: ?>
<p><?php _e( 'Sorry, no pages found.' ); ?></p>
<?php endif; ?>
I've faced a problem that there is a limit of 5 posts to be displayed by default. I tried to use custom WP_Query
:
<?php
$all_query = new WP_Query(array(
'post_type'=>'post',
'post_status'=>'publish',
'posts_per_page'=>-1,
));
if ($all_query->have_posts()) : while ($all_query->have_posts()) : $all_query->the_post();
?>
It shows all the posts, but it also shows all the posts even on category archive pages (i.e. posts from another category).
As I understand, I can create archive.php
page for categories and authors.
Is there any solution to use loop to show all the posts only of the current category or author?