Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

OK, I am creating a business listing site that is using a custom taxonomy for the listing "type". I need to display two loops on the taxonomy archive page, one for "sponsored" listings and one for regular ones.

taxonomy archive: http://pastie.org/3187162

pagination function: http://pastie.org/3187168

Both parts are doing exactly what I want, with one hitch: there are approx 50 non-sponsored listings in a specific category, but the 2nd query is maxing out at 5 "pages" (i.e. 25 listings if I set posts_per_page to 5, 35 if I set posts_per_page to 7)

I'm stumped. Any ideas?

UPDATE

FWIW, I've been testing the code layout here: http://www.kriesi.at/archives/how-to-build-a-wordpress-post-pagination-without-plugin and it's working a bit better, in that I get the total number of "pages" it should have. But it still gives me a 404 after page 5.

share|improve this question
    
Do you have more non-sponsored than sponsored listings? If you change those around so that there are more of whatever there are less of now, does the category that cannot list all its posts change? –  m0r7if3r Jan 15 '12 at 4:48
    
@m0r7if3r I'm not sure what you mean, but they're being displayed in the order I have to have them in. Both numbers can be variable, i.e. one type can have more sponsored than non-sponsored and vice versa. –  Norcross Jan 15 '12 at 5:01
    
Basically, what I'm thinking is that it is doing the pagination for the category with less entries, and when it reaches the end of those posts, it doesn't detect the second query, so the rest of the posts from the category with more entries cannot be displayed –  m0r7if3r Jan 15 '12 at 15:17
    
possible duplicate of How Do I Configure Automatic Updates in WordPress 3.7? –  Chip Bennett Oct 29 '13 at 22:34
add comment

2 Answers

up vote 2 down vote accepted

The issue is that before your custom queries load, WordPress runs the main taxonomy query (all results in that tax term, 10 per page). On page 6, the main query is trying to load posts 51-60, and since they don't exist the page 404's before you have a chance to load your custom query.

Customize the main query using the pre_get_posts hook so that the second loop you're doing is the main query. Add this to functions.php: https://gist.github.com/1616098

Then for your second loop, just do:

if( have_posts() ): while( have_posts() ): the_post();

More information: http://www.billerickson.net/customize-the-wordpress-query/

share|improve this answer
    
perfect! that was it. I had a feeling it was tied to the main posts per page setting. –  Norcross Jan 15 '12 at 15:16
add comment

Output the wp_query object on the 404 and see what is going on inside. It may provide some insight.

On your 404 template add global $wp_query; print_r($wp_query);

share|improve this answer
    
Thanks for the heads up. In doing so, I could see that it was grabbing the posts per page setting from the back-end. I change it to match the query in question, and it work. –  Norcross Jan 15 '12 at 14:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.