正常情况下,包括hypfx在内的个人博客都只有一个作者,因此是否显示作者名字似乎不是很重要。但hypfx昨天还是对博客主题做了一个很小的调整,可以在单篇日志页和整个首页显示hypfx.com的博客作者流星的名字。

       打开index.php和single.php文件,找到以<div class="postInfo">打头的语句,而后修改其语句代码为:

      <div class="postInfo"><div style="color:red;"><strong>由 <?php the_author_nickname(); ?> </strong>发表于 <?php the_time(‘F dS, Y’); ?> 分类于 <?php the_category(‘, ‘) ?> <?php edit_post_link(‘edit’, ‘(‘, ‘)’); ?></div></div>

       以上代码最终的显示效果就如hypfx的博客如今的显示效果:流星发表于 03月 17th, 2009 分类 xx。

       hypfx解释下这段代码的意思。
       <div style=”color:red;”>、<strong>都是用来定义作者流星的颜色为红色,并且为粗体。

       <?php the_author_nickname(); ?>这句是用来读取WordPress后台设定的作者昵称,如果不愿意使用昵称而要使用名字,也可以使用其它函数:the_author显示作者名字;the_author_login显示作者登录名;the_author_url显示作者的网站地址。

       <?php the_time(‘F dS, Y’); ?> 显示发布时间。

       <?php the_category(‘, ‘) ?> 显示文章分类。

       <?php edit_post_link(‘edit’, ‘(‘, ‘)’); ?>如果作者就是博客管理员,则会在登录状态下显示edit编辑按钮。

       建议以上修改直接在后台主题编辑器里面修改,不用考虑保存格式为UTF-8的问题。

无觅相关文章插件,快速提升流量

阅读更多和这篇相关的日志