I see that there are a lot of similar questions here at WPSE, and I've tried many of the suggestions mentioned trying to solve my problem but with no success.
I have a category called News. In this category I want to run a custom query using WP Query to fetch and display articles, spread out through multiple pages using the plugin WP-PageNavi. I manage to get the plugin to display the links (go back/forward or to a particular page) but when I click on either one I end up with a 404 page.
My permalink settings is "category/post-name/", for example I have "x.com/news/sample-news/. When trying to access let's say "x.com/news/page/2/" it gives me a 404.
Here's the code -
<?php $paged = get_query_var('paged') ? get_query_var('paged') : 1; $news = new WP_Query( array('category' => 3, 'paged' => $paged, 'posts_per_page' => 4, 'orderby' => 'date', 'order' => 'DESC') ); while ($news->have_posts()) : $news->the_post(); ?> <article> <?php the_post_thumbnail( array(466,9999), true ) ?> <h2><?php the_title() ?></h2> <h4><?php the_date() ?></h4> <?php the_content() ?> </article> <?php endwhile; if($news->max_num_pages>1) if(function_exists('wp_pagenavi')) wp_pagenavi( array('query' => $news) );?>
Using these plugins: Advanced Custom Fields, WP-PageNavi