您的位置:首页»WordPress 主题, 主题开发»  如何使你的主题兼容 WordPress2.7

如何使你的主题兼容 WordPress2.7

WordPress2.7 正式版已经发布两周多了,可许多主题作者仍然没有升级主题,使其完全支持 WordPress2.7。你是否只能眼睁睁看着 WordPress2.7 的嵌套评论(Threading Comments)、评论分页(Paging Comments)、日志置顶(post sticky)等诱人的功能而望洋兴叹呢?
不要垂头丧气,站趣-分享建站的乐趣就来介绍几个 WordPress 教程,用于改进你心爱的主题,使其支持 WordPress2.7。

  1. WordPress2.7 嵌套评论(Threading Comments)
  2. WordPress2.7 最令人欣喜的功能莫过于嵌套评论(Threading Comments)这个功能了,站趣-分享建站的乐趣制作的 eachBlueBlueweed for WprdPress2.7 这两个主题业已支持该功能,如果你的主题还不支持,强烈建议你下载试用,当然,你也可以和我一起,将主题彻底改造一下。效果图如下:
    eachBlue threading comments and paging comments

  3. WordPress2.7 评论分页(Paging Comments)
  4. WordPress 长长的评论页会将博客拖慢不少,WordPress2.7 之前,我们只有借助于插件才可以将评论分页,现在,我们可以使用 WordPress2.7 原生的 评论分页(Paging Comments)了。

  5. Post Classes
  6. WordPress2.7 推出之前,我们通常使用以下代码定义 Post Classes:

    <div id="post-<?php the_ID(); ?>" class="post">

    但在 WordPress2.7 中,WordPress 开发团队增强了 Post Classes 的功能,主题作者可以通过 Post Classes 实现文章置顶等功能。 使用方法:

    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

    我们甚至可以自定义 class 名称:

    <div id="post-<?php the_ID(); ?>" <?php post_class(style); ?>>

    style 可以是 post、category-slug、tag-slug、sticky(置顶)等值。

  7. Logout Link
  8. WordPress2.7 新增了 wp_logout_url 这个函数,我们可以在主题中使用它来注销登陆。使用方法:

    <a href="<?php echo wp_logout_url(); ?>">Logout</a>
  9. Search form
  10. WordPress2.7 对调用搜索函数也进行了改动,之前,我们都是使用以下代码调用搜索框:

    <?php include (TEMPLATEPATH.'/searchform.php'); ?>

    现在,我们可以使用更简洁的 get_search_form 函数调用 searchform.php 文件了,使用方法:

    <?php get_search_form(); ?>

文章很长,但是,为了体验 WordPress2.7 的新功能,折腾一下是值得的,你说呢?如果你还有什么疑问,请留言。

9个评论

  • Reply 1 aunsen

    December 29th, 2008 at 18:06

    抢沙发啊!

  • Reply 2 HK

    December 29th, 2008 at 21:49

    没沙发,抢板凳!哈哈
    不错,技术文章!

    • Reply 3 辐射鱼

      December 29th, 2008 at 21:54

      嘿嘿,欢迎常来哦,以后的非技术性文章还是有看头的

  • Reply 4 BeckW

    December 29th, 2008 at 23:25

    在以前的主题的head.php加上
    if(is_singular()) wp_enqueue_script(‘comment-reply’);
    然后在comment.php调用,再在form里设置上reply这些按钮就差不多了。
    不过博主分享的两个主题可以启到抛砖引玉的作用,不错不错!

    • Reply 5 辐射鱼

      December 29th, 2008 at 23:35

      WP一向不支持在文章和评论里插入php代码的。嵌套评论差不多就是那样,但细化还是得颇费些心思的

  • Reply 6 BeckW

    December 29th, 2008 at 23:27

    貌似我在评论里加的PHP代码消失掉了。。。
    看来我还是应该用

    标签引用起来。:)
  • Reply 7 白夏

    December 30th, 2008 at 01:29

    呵呵!
    支持一下
    很喜欢你们现在这个主题
    嗯嗯
    不知道什么时候放出呢?

    • Reply 8 辐射鱼

      December 30th, 2008 at 09:51

      喜欢就去下载 eachBlue 吧,本站使用的主题就是从它改过来的

    • Reply 9 yofox

      December 31st, 2008 at 10:20

      新年之后吧。