Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 134847

innersyncstudio on "Limit query to pull from one category w/o breaking pagination"

$
0
0

Hi, I'm new to PHP and WP,. I have the following code that pulls posts from a single category and lists them. The pagination appears correct, but when I go to page 2, it loads the same 10 posts. Here's my current code.

<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
<?php $query = new WP_Query('category_name=beekeeping'); ?>
<?php while($query->have_posts()): $query->the_post(); ?>

...Loop Stuff...

<?php endwhile; ?>

When I replace the query with:

<?php $query = new WP_Query(array('posts_per_page' => get_option('posts_per_page'),'paged' => $paged )); ?>

The pagination is correct, and works, but it pulls posts from ALL categories. I'm having a hard time trying to blend the two to get the desired result.

Here's the page on my site: http://m.allmorgan.com/beekeeping/
Notice at the bottom, there are 2 pages, but both return only the first/same 10 results.

Thank you, any help is appreciated. Jason


Viewing all articles
Browse latest Browse all 134847

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>