[Plugin Help] Pagination hacking, very small question
-
Okay basically right now wordpress allows you to limit X posts per page. It’s global for all pages such as front page, and your archives from what I know.
I limited in my settings 1 post per page. Only issue with that is – when viewing archives it’ll show one post per page. So I was working on a personal plug-in that modified the mysql query and pagination that displayed when viewing archives.
//Archives per page $g4mr_per_page = 10; //DONT EDIT BELOW add_filter('post_limits', 'archive_per_page_g4mr', 10, 2); function archive_per_page_g4mr($limits, $class) { global $g4mr_per_page, $wp_query; if(is_archive()) { $page = isset($class->query_vars['paged']) ? $class->query_vars['paged'] : 1; $page = $page <= 1 ? 1 : $page; $limit = @explode(", ", $limits); if($limit[1] <= 1) { $pstrt = ($page - 1) * $g4mr_per_page . ', '; $limits = 'LIMIT ' . $pstrt . $g4mr_per_page; } } return $limits; }Example: http://www.g4mr.net/2010/03/
Everything works as expected except I have no clue on how to actually make my script work with the following functions:
next_posts_link previous_posts_linkFrom what I seen in the source, the above functions are based on the global
$wp_query->max_num_pagesvariable.Is there a way to access and modify this variable correctly so my paging works better. I mean I have no problem with it right now, it’ll just have the “Previous posts” link on like every page practically.
Thanks for the support.
The topic ‘[Plugin Help] Pagination hacking, very small question’ is closed to new replies.