WordPress pure code paging function

WBOY
Release: 2016-07-25 08:49:23
Original
1206 people have browsed it
For relevant CSS configuration, see http://www.sjyhome.com/wordpress/pagenavi.html

Please place the following code in the theme functions.php file
  1. /*@pagination function*/
  2. function native_pagenavi(){
  3. global $wp_query, $wp_rewrite;
  4. $wp_query->query_vars["paged"] > 1 ? $current = $wp_query->query_vars ["paged"] : $current = 1;
  5. $pagination = array(
  6. "base" => @add_query_arg("page","%#%"),
  7. "format" => "",
  8. " total" => $wp_query->max_num_pages,
  9. "current" => $current,
  10. "prev_text" => "? ",
  11. "next_text" => " ?"
  12. );
  13. if( $ wp_rewrite->using_permalinks() )
  14. $pagination["base"] = user_trailingslashit( trailingslashit( remove_query_arg("s",get_pagenum_link(1) ) ) . "page/%#%/", "paged");
  15. if ( !empty($wp_query->query_vars["s"]) )
  16. $pagination["add_args"] = array("s"=>get_query_var("s"));
  17. echo paginate_links($pagination);
  18. }
Copy code


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template