做网站公司电话,seo公司网站推广,中国城乡建设网,免费wordpress空间原本的wordpress文章如果分页会成如下的结构#xff1a;http://www.xyqzmt.cn/1.html/2通常固定链接都是这样的结构#xff0c;设为/%postname%.html或者/%post_id%.html 以前我一直无法解决如上的问题#xff0c;最后放弃挣扎#xff0c;如果遇到很长的文章全都放在一个页…原本的wordpress文章如果分页会成如下的结构http://www.xyqzmt.cn/1.html/2通常固定链接都是这样的结构设为/%postname%.html或者/%post_id%.html 以前我一直无法解决如上的问题最后放弃挣扎如果遇到很长的文章全都放在一个页面里面。今天在知更鸟大佬的博客上找到了结局办法。http://zmingcx.com/pseudo-static-article-page-links.html将下面代码添加到当前主题 functions.php中本文提供一下/%post_id%.html的修改方法。// 适合/%post_id%.html分页链接修正class Rewrite_Inner_Page_Links_id{var $separator;function __construct(){$this-separator ‘/page-‘;if( !is_admin() || defined( ‘DOING_AJAX’ ) ) :add_filter( ‘wp_link_pages_link’, array( $this, ‘inner_page_link_format’ ), 10, 2 );add_filter( ‘get_comments_pagenum_link’, array( $this, ‘comment_page_link_format’ ) );add_filter( ‘redirect_canonical’, array( $this, ‘cancel_redirect_for_paged_posts’ ), 10, 2 );endif;if( is_admin() ) :add_filter( ‘rewrite_rules_array’, array( $this, ‘pagelink_rewrite_rules’ ) );register_activation_hook( __FILE__, array( $this, ‘flush_rewrite_rules’ ) ) ;register_deactivation_hook( __FILE__, array( $this, ‘flush_rewrite_rules’ ) );endif;}function flush_rewrite_rules(){flush_rewrite_rules();}// 修改post分页链接的格式function inner_page_link_format( $link, $number ){if( $number 1 ){if( preg_match( ‘%$link preg_replace( “%(\.html)/(\d*)%”, $this-separator.”$2$1″, $link );}}return $link;}// 为新的链接格式增加重定向规则,移除原始分页链接的重定向规则防止重复收录function pagelink_rewrite_rules( $rules ){foreach ($rules as $rule $rewrite) {if ( $rule ‘([0-9]).html(/[0-9])?/?$’ ) {unset($rules[$rule]);}}$new_rule[‘([0-9])(‘.$this-separator.([0-9]))?.html/?$’] ‘index.php?p$matches[1]page$matches[3]’;return $new_rule $rules;}// 禁止WordPress将页面分页链接跳转到原来的格式function cancel_redirect_for_paged_posts( $redirect_url, $requested_url ){global $wp_query;if( is_single() $wp_query-get( ‘page’ ) 1 ){return false;}return true;}}new Rewrite_Inner_Page_Links_id();提示添加代码后需要保存一下固定链接设置。之后再次打开文章分页链接会变成类似的/morning-paper-news/page-2.html/132/page-2.html解决了我的千古难题我弄的那个漫画教程网站复制贴吧里面的教程有大量的图片起码要分个七八页才OK的。增加网站的PV也挺好的前提就是内容足够吸引人等有机会再研究那种能整页展示分页的功能。(参考太平洋电脑网上的那种)