{"id":581,"date":"2019-10-15T16:13:23","date_gmt":"2019-10-15T08:13:23","guid":{"rendered":"https:\/\/www.linuxdevops.cn\/?p=581"},"modified":"2019-10-15T16:15:37","modified_gmt":"2019-10-15T08:15:37","slug":"wordpress-new-page-paging","status":"publish","type":"post","link":"https:\/\/www.linuxdevops.cn\/2019\/10\/wordpress-new-page-paging\/","title":{"rendered":"WordPress\u65b0\u5efa\u9875\u9762\uff0c\u5206\u9875"},"content":{"rendered":"\n
<?php\n\/*\nTemplate Name: test1\n*\/\n?>\n<?php\n\nget_header();\ndo_action( 'ample_blog_breadcrumb_type' );\n?>\n\n <head>\n <title>\u7f51\u7ad9\u6536\u85cf<\/title>\n <\/head>\n<!--\/\/\u5185\u5bb9-->\n <div class=\"col-md-8 content-wrap\" id=\"primary\">\n <table class=\"table-hover \">\n <tr class=\"active\">\n <td class=\"td\">ID<\/td>\n <td class=\"td\">\u7f51\u7ad9<\/td>\n <td class=\"td\">\u7f51\u5740<\/td>\n <td class=\"td\">\u7b80\u4ecb<\/td>\n <\/tr>\n <?php\n $total = $wpdb->get_var(\"select count<\/em>(*) from wp_collection\");\n $comments_per_page = 3;\n $page = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1;\n $nowPage = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1;\n $offset = ($nowPage-1)*$comments_per_page;\n $results = $wpdb->get_results(\"select * from wp_collection ORDER BY id limit $offset , $comments_per_page\");\n foreach ($results as $result) {\n ?>\n <tr class=\"success\">\n <td class=\"td\"><?php echo $result->id ?><\/td>\n <td class=\"td\"><?php echo $result->site_name ?><\/td>\n <td class=\"td\"><a href=\"<?php echo $result->url ?>\" target=\"_blank\"><?php echo $result->url ?><\/a><\/td>\n <td class=\"td\"><?php echo $result->jianjie ?><\/td>\n <\/tr>\n\n <?php } ?>\n\n <\/table>\n <div class=\"pager\">\n <?php\n echo paginate_links( array(\n 'base' => add_query_arg( 'cpage', '%#%' ),\n 'format' => '',\n 'prev_text' => __('\u4e0a\u4e00\u9875;'),\n 'next_text' => __('\u4e0b\u4e00\u9875;'),\n 'total' => ceil($total \/ $comments_per_page),\n 'current' => $page\n ));\n ?>\n <\/div>\n <\/div>\n\n<!--\/\/\u53f3\u4fa7-->\n <div class=\"col-md-4 sidebar-wrap\" id=\"secondary\">\n <?php get_sidebar(); ?>\n <\/div>\n<!--\/\/\u9875\u811a-->\n<?php\nget_footer();\n?><\/pre>\n\n\n\n