optional: you can pass two strings to print_pg_navigation. The first string is what will appear BEFORE the page navigation. The second string is what will appear AFTER the page navigation. NOTHING will be displayed if no navigation is appearing on the page. So, when there was navigation, if you wanted to have the navigation surrounded by

tags, you would the following: ','

'); ?> adjut settings below if you would like to set custom posts per page - this plugin will work in conjunction with the Custom Posts Per Page plugin: http://wordpress.org/support/6/11211 */ //text to show between page links $pageNavDivider = " | "; //turn on "brief navigation" if over this many pages //if you want brief navigation on always - set this number to 0 $turnOnBriefNavWhenOver = 5; //used for brief navigation - how many pages on either side of current page before truncating $navpad = 3; //set anything below to false if you do not want to paginate on that page. $paginate_on['home'] = TRUE; $paginate_on['day'] = TRUE; $paginate_on['month'] = TRUE; $paginate_on['search'] = TRUE; $paginate_on['year'] = TRUE; $paginate_on['author'] = TRUE; $paginate_on['category'] = TRUE; /* end custom settings - do not edit below - unless you know what you're doing */ function wpPaginate($query_string) { global $paginate_on, $pageNavDivider, $navpad, $turnOnBriefNavWhenOver; global $paginationNavigation; parse_str($query_string); if (!preg_match("/posts_per_page=/", $query_string)) { $posts_per_page = get_settings('posts_per_page'); } if (!preg_match("/paged=/", $query_string)) { $paged = 1; } $query = new WP_Query(); $query->parse_query($query_string); if ($query->is_home && $paginate_on['home']) { $num = $posts_per_page; } elseif ($query->is_day && $paginate_on['day']) { $num = $posts_per_page; } elseif ($query->is_month && $paginate_on['month']) { $num = $posts_per_page; } elseif ($query->is_year && $paginate_on['year']) { $num = $posts_per_page; } elseif ($query->is_author && $paginate_on['author']) { $num = $posts_per_page; } elseif ($query->is_category && $paginate_on['category']) { $num = $posts_per_page; } elseif ($query->is_search && $paginate_on['search']) { $num = $posts_per_page; } //if we're on a page that should be paginated... if (isset($num)) { //first get total number of pages possible $tempquery_string = $query_string; //$tempquery_string = add_query_arg('nopaging', true, $tempquery_string); if (preg_match("/posts_per_page=/", $tempquery_string)) { $tempquery_string = preg_replace("/posts_per_page=[0-9]*/", "posts_per_page=-1", $tempquery_string); } else { if ($tempquery_string != '') { $tempquery_string .= '&'; } $tempquery_string = $tempquery_string."posts_per_page=-1"; } if (preg_match("/paged=/", $tempquery_string)) { $tempquery_string = preg_replace("/paged=[0-9]*/", "paged=1", $tempquery_string); } else { $tempquery_string .= '&paged=1'; } update_category_cache(); $tempposts = query_posts($tempquery_string); $num_of_pages = ceil(count($tempposts)/$num); if ($num_of_pages > $turnOnBriefNavWhenOver) { $briefnavigation = TRUE; } else { $briefnavigation = FALSE; } $paginationNavigation = ''; //now update querystring so that posts per page reflect changes, and paged value is added... if (preg_match("/posts_per_page=/", $query_string)) { $query_string = preg_replace("/posts_per_page=[0-9]*/", "posts_per_page=".$num, $query_string); } else { if ($query_string != '') { $query_string .= '&'; } $query_string .= "posts_per_page=".$num; } if (preg_match("/paged=/", $query_string)) { $query_string = preg_replace("/paged=[0-9]*/", "paged=".$paged, $query_string); } else { $query_string .= '&'; $query_string .= "paged=".$paged; } //compose navigation if ($num_of_pages > 1) { $paginationNavigation .= "Page: "; } if ($briefnavigation) { $lowtest = $paged - $navpad; $hightest = $paged + $navpad; } if ($num_of_pages > 1) { for ($i = 1; $i <= $num_of_pages; $i++) { //Make the navigation //Make a link for page 1 and the last page, and for pages paged-$navpad to paged+$navpad //Also make all page links if $briefnavigation == false if ((!$briefnavigation) || ($i == 1 || $i == $num_of_pages || ($i > $lowtest && $i < $hightest))) { if ($i != 1) { $paginationNavigation .= $pageNavDivider; } //are we on the current page? if ($paged != $i) { $paginationNavigation .= "$i"; } else { $paginationNavigation .= $i; } } else { //Add the divider. If the string ends in an ellipsis ('...') then do nothing if (!preg_match ("/\.\.\.\$/", $paginationNavigation)) { $paginationNavigation .= $pageNavDivider."..."; } } } // end creating navigation } } // end if isset num return $query_string; } //end wp-paginate() function function print_pg_navigation ($before = '', $after = '') { global $paginationNavigation; if ($paginationNavigation != '') { echo $before.$paginationNavigation.$after; } } add_filter('query_string', 'wpPaginate'); ?>