数字化技能提升教程,数字化时代生存宝典

数字化百科 / 产品文档 / WordPress:Post Meta Data Section

WordPress:Post Meta Data Section

查看全部产品文档命名空间:WordPress

文章 meta数据是提供给访问者的每个文章的"管理的"信息。这个

信息通常包括作者、写(或是发布)的时间和作者如何分类这篇文章。

这一课将告诉你一些改变主题设计,使用你想要的方法来显示这些重要信息的方法。

在很多情况下,文章 meta数据会在文章自身形成后立即形成,一些主题设计成把这些信息放在文章

顶部,别的一些主题可能会放在顶部或者底部的边栏中,还有一些写主题甚至放在页脚。基本上,文章 meta数据可以设计成不同的方式,带有不同的多种细节内容。

默认用法

默认的WordPress 主题文章 meta数据这基本信息和标签定位在文章
下部分,在评论之前的一个信息框中。简化的代码如下:

This entry was posted on 
at
and is filed
under . You
can follow any responses to this entry
through the
feed.

这输出结果如下:

This

entry was posted on Monday, February 12, 2003 at 11:32 and is filed under

WordPress Lessons, Things to Know.

You can follow any responses to this entry though the RSS 2.0

feed.

文章 meta数据中有3种模板标签可以使用,第一,

the_time(),使用两次带有不同的结果,另外两种标签是

得到关于分类的信息和从数据库到RSS feed的连接。

the_time()的模板标签有很多显示数据库中的文章时间和日期的参数可以设置。第一种用法,

l, F jS, Y参数,把文章的日期设置成一个周日, 月, 日, and 的格式,第二种用

法,没有任何参数,这样它只是返回文章是什么时候保存的值。你在下面的更改时间和日期中就会体会到。

模板标签the_category()显示文章所属的

分类。这个模板标签可以更改来适应不同的文本、图片、图片之间的

符号,还可以使用插件来代替文字显示图片。有很多种设计方法。在这个例子中列出的

分类使用逗号分开它们

最后一个标签是comments_rss_link(),使

用参数RSS 2.0来识别使用的feed类型。你也可以

自定义feed标签,更改它的显示有关feed和模型的连接信息的方式,

或者使用feed图标来代替文本。

更改文本

让我们开始重新排版你的文章 meta数据。第一步是更改文本而不是标签。毕竟,这是你的网站,你

希望它使用你的方式来排列,对吧?这个例子让文章 meta数据更加会话式:

I slaved away at the computer on  
at the ridiculous time of when I could have
been doing something much more productive. I slapped this
thing into the categories, just
to make you think I have some organizational skills. If you
can really be bothered, you can keep track of what people
have to say about my silly writings through the
feed, but I
wouldn't bother. No one else who reads this babble has
anything worthwhile to say.

显示结果如下:

I slaved away at the

computer on Monday, February 12, 2003 at the ridiculous time of 11:32. when I could have

been doing something much more productive. I slapped this thing into the

WordPress Lessons and Things

to Know. categories, just to make you think I have some organizational skills. If you can

really be bothered, you can keep track of what people have to say about my silly writings

through the RSS 2.0 feed, but I wouldn't bother. No one

else who reads this babble has anything worthwhile to say.

好了,有一点小的变化,你发现了吗?

the_category()模板标签的使用,设置分类列表分离

的参数,文章所在的地方,从一个逗号 (,)更改为单词"and",这样它更加有意义了。

现在可以中断一下,让你的文章 meta数据更短,更有味道:

POSTED: 

FILED AS:

COMMENTS FEED:

这是你的文章 meta数据中很短的一个列表:

POSTED:

05/12/04 9:35 AM
FILED AS: News, Answers
COMMENTS FEED: RSS 2.0

更改日期和时间

文章 meta数据中有很多种方法更改时间和日期,来反映出对你的网站或者是你时间文化更合适的用

法,举个例子,世界上很多地方不是月 日, 年而是日 月, 年。在文章 meta数据中,你可

以改变the_time()模板标签,这样参数就会显

示"Monday, 21 February 2005"了:

想加入更多有趣的信息到文章 meta数据中,有几种插件可以使用,它们可以得到文章最后更改的时

间。两种这样的插件Kaf Oseo's Post

UpdatedNick Momrik's Last

Modified,在下边的例子中,使用manipulating time带有

PHP标签的不同方法,我们会把Nick Momrik的插件加入混合,mdv_last_modified()

显示结果如下:

This post was written on

what I think was a Tuesday, but I know it was the 15th day in the month of February in the

year of 2004, though I messed around with this on the 10th day of August in 2004, a not-so-

busy Thursday when I had nothing better to do.

添加模板标签

到目前为止,你涉及了可以加入文章 meta数据的仅仅三种标签。你可以添加

the_title()来得到文章的标题。如果你想要作者的名字

,你可以添加the_author(),还可以添加

the_author_email()以得到作者的电子邮件。想

要某个作者的所有文章的连接?可以使用the_author_posts_link()来安排妥当。

如果你想包括更基本的信息比如网站使用的标题,使用bloginfo()或者导航帮助

previous_post()next_post()?我们使用WordPress 1.5.1.3+的使用者可用的,上一个和下一个

文章模板标签来列出同一列表中的文章。这些只是文章 meta数据中很多可能的模板标签用法的几个

例子。

在最简单的用法中,文章 meta数据可以如下列出

POST TITLE: 

AUTHOR:

POSTED:

FILED AS:

COMMENT FEED:

PREVIOUS: , 'yes', 'yes'); ?>

NEXT: , 'yes', 'yes'); ?>

显示如下:

POST TITLE:

WordPress Makes Me Smile

AUTHOR: Harriet Smith

POSTED: 20 April 2004

FILED AS: WordPress, News

COMMENT FEED: RSS 2.0

PREVIOUS: Things to Do With WordPress

NEXT: Why I Like WordPress

如果你想让这些内容显示在边栏中,而且你想要一个会话式的样式,那么在你的

模板文件中,sidebar.php,找一个地方输入以下内容:

这个例子如果被规划在一个大多数边栏的窄栏目中,将显示如下:

You are reading the article, WordPress Makes Me

Smile, on our website, Talking Blog. This article was

written on May 15, 2004, in Seattle, Washington, and you can find similar articles in the

WordPress and Blog

categories, or more articles by Harriet Smith, if you

enjoyed this article. If you have any comments about this article, you can contact Harriet

Smith by email, or leave a comment below. You can also

follow comments made on this article via our RSS 2.0

feed.

If you would like to continue reading more, the previous article on our site is called

Things To Do With WordPress and the next article is

called Why I Like WordPress. Thank you for visiting our

site.

这只是开始,有很多设计你的''文章 meta数据''的方法:通过

把它放入文本框,把它变为文本的一部分,把它在列表中列出等等。这都取决于你希望如何设计你的

文章 meta数据,和你想通过你的文章分享什么样的信息。

更多资源