[wp-hackers] Taxonomy - Custom Post Type - Pagination?

Philip M. Hofer (Frumph) philip at frumph.net
Mon Sep 20 13:14:04 UTC 2010


Well the reason is the posts_per_page when set in the query line doesn't 
actually work unless you send it to the pre_get_posts first, the reason is 
that the calculation for pagination happens *way* before the query is done, 
dunno why, just does.

  add_filter('pre_get_posts', 'comicpress_blogpostcount_filter');

  function comicpress_blogpostcount_filter($query) {
   if (is_home()) {
    $query->set('posts_per_page', 16);
   }
   return $query;
  }

So basically you need to set it at the pre_get_posts stage ahead of time so 
that it can calculate the posts_per_page properly


----- Original Message ----- 
From: "Joaquin Rodriguez Montero" <yojoaquin at gmail.com>
To: <wp-hackers at lists.automattic.com>
Sent: Monday, September 20, 2010 6:10 AM
Subject: Re: [wp-hackers] Taxonomy - Custom Post Type - Pagination?


> Thanks Philip. When I do that I get "extra empty pages" in the pagination,
> as if it was not counting posts_per_page...
>
> ----- Original Message -----
> Date: Sun, 19 Sep 2010 20:13:47 -0700
> From: "Philip M. Hofer \(Frumph\)" <philip at frumph.net>
> Subject: Re: [wp-hackers] Taxonomy - Custom Post Type - Pagination?
> To: <wp-hackers at lists.automattic.com>
> Message-ID: <FC8456E0DCA74249AA68775B569C3CE8 at frumph.net>
> Content-Type: text/plain; format=flowed; charset="iso-8859-1";
>       reply-type=original
>
> ".$page."  (or)  {$page}
>
> its not translating into the string otherwise.
>
> ----- Original Message -----
> From: "Joaquin Rodriguez Montero" <yojoaquin at gmail.com>
> To: <wp-hackers at lists.automattic.com>
> Sent: Sunday, September 19, 2010 7:55 PM
> Subject: [wp-hackers] Taxonomy - Custom Post Type - Pagination?
>
>
>> Hi guys,
>>
>> I'm sure this is really simple but I can't seem to find out what's going
>> on.
>>
>> I'm trying to do the following on my taxonomy-term.php
>>
>> $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
>> query_posts("
>> post_type=postype&
>> paged=$page&
>> posts_per_page=16&
>> orderby=title&
>> order=ASC&
>> term=$termslug");
>> $i = 1; while (have_posts()) : the_post();
>>
>> Result: list of posts ok, pagination wrong. It's getting the pagination 
>> as
>> if it was querying every post. Why I wanna do it this way? Cause I want 
>> to
>> get the posts ordered by title.
>>
>> Any clue that could help me?
>>
>> Thanks!
>>
>> J
>> ______________________________
> _________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
> 




More information about the wp-hackers mailing list