How to add article list page number navigation in WordPress topic
This article mainly shows you the "WordPress theme how to add article list page navigation", the content is easy to understand, well-organized, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to add article list page navigation in the WordPress theme" this article.
WordPress's default advice to theme developers is to provide upper and lower page buttons at the bottom of the article list, so there is no paging navigation function that can be used directly under the article list. Here I provide a relatively perfect paging navigation function.
/ * * WordPress article list paging navigation * http://www.endskin.com/page-navi/*/function Bing_get_pagenavi ($query = false, $num = false, $before ='', $after ='', $options = array ()) {global $wp_query $options = wp_parse_args ($options, array ('pages_text' = >'% CURRENT_PAGE%/%TOTAL_PAGES%', 'current_text' = >'% PAGE_NUMBER%', 'page_text' = >'% PAGE_NUMBER%', 'first_text' = > _ («home page', 'Bing'),' last_text' = > _ ('last page »', 'Bing')) 'next_text' = > _ (' »', 'Bing'),' prev_text' = >'«', 'dotright_text' = >'...', 'dotleft_text' = >'...', 'num_pages' = > 5,' always_show' = > 0, 'num_larger_page_numbers' = > 3,' larger_page_numbers_multiple' = > 10)) If ($wp_query- > max_num_pages request; $numposts = $query- > found_posts; $max_page = $query- > max_num_pages; $posts_per_page = intval ($num);} else {$request = $wp_query- > request; $numposts = $wp_query- > found_posts; $max_page = $wp_query- > max_num_pages; $posts_per_page = intval (get_query_var ('posts_per_page')) } $paged = intval (get_query_var ('paged')); if (empty ($paged) | | $paged = = 0) $paged = 1; $pages_to_show = intval ($options [' num_pages']); $larger_page_to_show = intval ($options ['num_larger_page_numbers']); $larger_page_multiple = intval ($options [' larger_page_numbers_multiple']); $pages_to_show_minus_1 = $pages_to_show-1 $half_page_start = floor ($pages_to_show_minus_1 / 2); $half_page_end = ceil ($pages_to_show_minus_1 / 2); $start_page = $paged-$half_page_start; if ($start_page $max_page) {$start_page = $max_page-$pages_to_show_minus_1; $end_page = $max_page;} if ($start_page $max_page) $larger_end_page_end = $max_page If ($max_page > 1 | intval ($options ['always_show']) = = 1) {$pages_text = str_replace ('% CURRENT_PAGE%', number_format_i18n ($paged), $options ['pages_text']); $pages_text = str_replace ('% TOTAL_PAGES%', number_format_i18n ($max_page), $pages_text); echo $before; if (! empty ($pages_text) echo''. $pages_text. '; if ($start_page > = 2 & & $pages_to_show
< $max_page ){ $first_page_text = str_replace( '%TOTAL_PAGES%', number_format_i18n( $max_page ), $options['first_text'] ); echo '' . $first_page_text . ''; } if( $larger_page_to_show >0 & & $larger_start_page_start > 0 & $larger_start_page_end 0 & & $larger_end_page_start < $max_page) {for ($I = $larger_end_page_start;$i)