效果:将下面的函数放到你的主题的 functions.php 文件中:复制代码 代码如下:function theme_echo_pagenavi(){ global $request, $posts_per_page, $wpdb, $paged; $maxButtonCount = 9; //显示的最多链接数目 if (!is_single()) { if(!is_category()) { preg_match(‘#FROM\s(.*)\sORDER BY#siU‘, $request, $matches); } else { preg_match(‘#FROM\s(.*)\sGROUP BY#siU‘, $request, $matches); } $fromwhere = $matches[1]; $n...
效果:将下面的函数放到你的主题的 functions.php 文件中: 代码如下:function theme_echo_pagenavi(){ global $request, $posts_per_page, $wpdb, $paged; $maxButtonCount = 9; //显示的最多链接数目 if (!is_single()) { if(!is_category()) { preg_match(#FROM\s(.*)\sORDER BY#siU, $request, $matches); } else { preg_match(#FROM\s(.*)\sGROUP BY#siU, $request, $matches); } $fromwhere = $matches[1]; $numposts = $wpdb-...
入门菜鸟,希望能给和菜鸟相互取暖 最近在改造wordpress,自己写代码做了个分页 1,在自己主题下的style.css中增加如下css Js代码 .pagination {width: auto;display: block;text-align: center;margin: 30px;
}
.pagination a {background-color: #eee;text-decoration: none;color: #999;font-size: 18px;padding: 0px 10px;line-height: 32px;height: 32px;margin: 0px 0.5px;
}
.pagination a.page-btn {width: 40px;
}
.pagi...
先看效果使用后链接地址为:http://localhost/news/paged/1.html 1、添加过滤器使用链接地址添加.html后缀add_filter( get_pagenum_link ,my_get_pagenum_link ,1 ,1 ); function my_get_pagenum_link( $url ) { return str_replace(.html, , $url)..html; }2、添加重写规则if( !is_admin() ) //只有前端页面应用{ add_action(init , my_post_rewrite ); }function my_post_rewrite(){ global $wp_...
相关的CSS配置见 http://www.sjyhome.com/wordpress/pagenavi.html以下代码请放置主题functions.php文件当中/*@分页功能*/function native_pagenavi(){global $wp_query, $wp_rewrite;$wp_query->query_vars["paged"] > 1 ? $current = $wp_query->query_vars["paged"] : $current = 1;$pagination = array("base" => @add_query_arg("page","%#%"),"format" => "","total" => $wp_query->max_num_pages,"current" => $current,"pr...
效果:将下面的函数放到你的主题的 functions.php 文件中: 代码如下:function theme_echo_pagenavi(){ global $request, $posts_per_page, $wpdb, $paged; $maxButtonCount = 9; //显示的最多链接数目 if (!is_single()) { if(!is_category()) { preg_match(#FROM\s(.*)\sORDER BY#siU, $request, $matches); } else { preg_match(#FROM\s(.*)\sGROUP BY#siU, $request, $matches); } $fromwhere = $matches[1]; $numposts = $wpdb-...
插件太多总是不好的,本着能不用就不用的原则,网上找了下,这个方法可行。1.打开wp-includes下面的functions.php文件,插入这段代码://分页 免插件 自己加的function par_pagenavi($range = 4){global $paged, $wp_query;if ( !$max_page ) {$max_page = $wp_query->max_num_pages;} if($max_page > 1){if(!$paged){$paged = 1;} if($paged != 1){echo “ 返回首页 ”;} previous_posts_link(‘ 上一页 ‘);if($max_page > $rang...
WordPress分页伪静态加html后缀,wordpress问题
当文章有分页的时候,WordPress生成的永久链接是page.html/2的形式,前面一段是文章的$link,后面的数字代表分页$number。那么问题来了,挖掘……不对,从逻辑上讲这到底是个html文件还是一个目录呢?
难看
在.html这个静态文件后面加上一个/和数字简直令人摸不着头脑,这还只是其次,重要的是,我发现搜索引擎根本不收录这样奇怪的链接,这个真是无法接受,我写的东西首尾都很重要,...
小弟在开发时遇到个问题,思路大概是这样的:设置四种文章类型('post','detail','jingyan','haitao),相当于与后台的「文章」同级。
在首页调取四种文章类型中的所有内容,如下:$notcat,'post__not_in' => $sticky,'post_type'=>array( 'post','detail','jingyan','haitao'),'posts_per_page' => 15,'paged' => $paged);query_posts( $args );
?>...Functions.php 加了这些:
set('post_type',$post_type);$query->set('posts_per...
方法说明
首先来看看可能被用到的方法. 打开文件 wp-includes/link-template.php 你会发现 WordPress 2.7 多了 4 个针对评论分页的方法:
get_comments_pagenum_link$pagenum: 页码$max_page: 最大页数返回链接地址. 在本次应用中不会被用到, 但大家应该知道有这个方法, 将方便你制作插件.
next_comments_link
$label: 显示的字样, 默认是 Newer Comments. 但我一直认为这是 bug, 应该是 Newer Comments 吧?
$max_page: 最大页数
...
效果:将下面的函数放到你的主题的 functions.php 文件中: 代码如下:function theme_echo_pagenavi(){ global $request, $posts_per_page, $wpdb, $paged; $maxButtonCount = 9; //显示的最多链接数目 if (!is_single()) { if(!is_category()) { preg_match(#FROM\s(.*)\sORDER BY#siU, $request, $matches); } else { preg_match(#FROM\s(.*)\sGROUP BY#siU, $request, $matches); } $fromwhere = $matches[1]; $numposts = $wpdb-...
方法说明
首先来看看可能被用到的方法. 打开文件 wp-includes/link-template.php 你会发现 WordPress 2.7 多了 4 个针对评论分页的方法:
get_comments_pagenum_link$pagenum: 页码$max_page: 最大页数返回链接地址. 在本次应用中不会被用到, 但大家应该知道有这个方法, 将方便你制作插件.
next_comments_link
$label: 显示的字样, 默认是 Newer Comments. 但我一直认为这是 bug, 应该是 Newer Comments 吧?
$max_page: 最大页数
...
效果:将下面的函数放到你的主题的 functions.php 文件中: 代码如下:function theme_echo_pagenavi(){ global $request, $posts_per_page, $wpdb, $paged; $maxButtonCount = 9; //显示的最多链接数目 if (!is_single()) { if(!is_category()) { preg_match(#FROM\s(.*)\sORDER BY#siU, $request, $matches); } else { preg_match(#FROM\s(.*)\sGROUP BY#siU, $request, $matches); } $fromwhere = $matches[1]; $numposts = $wpdb-...
方法说明
首先来看看可能被用到的方法. 打开文件 wp-includes/link-template.php 你会发现 WordPress 2.7 多了 4 个针对评论分页的方法:
get_comments_pagenum_link$pagenum: 页码$max_page: 最大页数返回链接地址. 在本次应用中不会被用到, 但大家应该知道有这个方法, 将方便你制作插件.
next_comments_link
$label: 显示的字样, 默认是 Newer Comments. 但我一直认为这是 bug, 应该是 Newer Comments 吧?
$max_page: 最大页数
...
问题
当文章有分页的时候,WordPress生成的永久链接是page.html/2的形式,前面一段是文章的$link,后面的数字代表分页$number。那么问题来了,挖掘……不对,从逻辑上讲这到底是个html文件还是一个目录呢?
难看
在.html这个静态文件后面加上一个/和数字简直令人摸不着头脑,这还只是其次,重要的是,我发现搜索引擎根本不收录这样奇怪的链接,这个真是无法接受,我写的东西首尾都很重要,不能因为分个页就被忽视了。
不收录
拿这篇...