Tag: 静态化

  • 巧妙美化静态化文章分页链接结构

    前天和大家分享的“如何实现Wordpress文章分页”反响很好,但现在很多WPer都静态化了自己的的Blog,Wopus中文平台也一样,采用了“%postname%.html”这样的链接形式,分页后就变成了“postname.html/2”的形式,相当不美观,我们需要“postname-2.html”这样的形式,来,动两个小手术:

    1. 修改wp-includes/rewrite.php 文件
    2. 找到 $rewrite = array_merge($rewrite, array($match => $query))
      在这行代码之前添加以下代码:

      if (strpos($match, ‘.html’) !== false && strpos($query, ‘&page=’) !== false) {
      $match = str_replace(‘(/[0-9]+)?/?$’, ‘$’, $match);
      $rewrite = array_merge($rewrite, array(str_replace(‘([^/]+).html’, ‘([^/]+)-([0-9]+).html’, $match) => $query));
      }

    3. wp-includes/post-template.php 文件
    4. 找到wp_link_pages函数,用以下代码替代之:
      (more…)