|
|
(未显示同一用户的1个中间版本) |
第1行: |
第1行: |
| __TOC__ | | __TOC__ |
| The '''post meta data''' is the "administrative" information you provide to viewers about
| |
|
| |
| each [[WordPress:Glossary#Post|post]]. This information usually includes the author of the
| |
|
| |
| post, when it was written (or posted), and how the author
| |
|
| |
| [[WordPress:Glossary#Category|categorized]] that particular post. This lesson will show you
| |
|
| |
| some different ways to change your Theme design to display these important pieces of
| |
|
| |
| information in the manner you desire.
| |
|
| |
| '''文章 meta数据'''是提供给访问者的每个[[WordPress:Glossary#Post|文章]]的"管理的"信息。这个 | | '''文章 meta数据'''是提供给访问者的每个[[WordPress:Glossary#Post|文章]]的"管理的"信息。这个 |
|
| |
|
第17行: |
第5行: |
|
| |
|
| 这一课将告诉你一些改变主题设计,使用你想要的方法来显示这些重要信息的方法。 | | 这一课将告诉你一些改变主题设计,使用你想要的方法来显示这些重要信息的方法。 |
|
| |
| In many cases, the ''post meta data'' is positioned immediately following the post itself,
| |
|
| |
| though some Themes are designed to place this information at the top of the post, other
| |
|
| |
| designs feature the ''post meta data'' in the top or bottom of the sidebar, and some designs
| |
|
| |
| even place the information in the footer. Essentially, ''post meta data'' can be styled in
| |
|
| |
| many different ways and with a variety of details.
| |
|
| |
|
| 在很多情况下,''文章 meta数据''会在文章自身形成后立即形成,一些主题设计成把这些信息放在文章 | | 在很多情况下,''文章 meta数据''会在文章自身形成后立即形成,一些主题设计成把这些信息放在文章 |
|
| |
|
| 顶部,别的一些主题可能会放在顶部或者底部的边栏中,还有一写主题甚至设计成放在页脚。如果需要的
| | 顶部,别的一些主题可能会放在顶部或者底部的边栏中,还有一些写主题甚至放在页脚。基本上,''文章 meta数据''可以设计成不同的方式,带有不同的多种细节内容。 |
| 话''文章 meta数据''可以设计成不同的方式,带有不同的多种细节内容。
| |
| | |
| ==Default Usage==
| |
| | |
| The default WordPress [[WordPress:Using Themes|Theme]] places the ''post meta data'' basic
| |
| | |
| information and tags below the post in a box, before the comments. A condensed version of
| |
| | |
| the code looks like this:
| |
| | |
| <pre><small>This entry was posted on
| |
| <?php the_time('l, F jS, Y') ?> at
| |
| <?php the_time() ?> and is filed
| |
| under <?php the_category(', ') ?>. You
| |
| can follow any responses to this entry
| |
| through the <?php comments_rss_link('RSS 2.0'); ?>
| |
| feed.</small></pre>
| |
|
| |
|
| ==默认用法== | | ==默认用法== |
第61行: |
第22行: |
| through the <?php comments_rss_link('RSS 2.0'); ?> | | through the <?php comments_rss_link('RSS 2.0'); ?> |
| feed.</small></pre> | | feed.</small></pre> |
|
| |
| The output result looks like this:
| |
|
| |
| <div style="border:1px solid #afafca; background: #F2F2F2; margin: 10px; padding:20px">This
| |
|
| |
| entry was posted on Monday, February 12, 2003 at 11:32 and is filed under
| |
|
| |
| [[WordPress:#Default Usage|WordPress Lessons]], [[WordPress:#Default Usage|Things to Know]].
| |
|
| |
| You can follow any responses to this entry though the [[WordPress:#Default Usage|RSS 2.0]]
| |
|
| |
| feed.</div>
| |
|
| |
|
| 这输出结果如下: | | 这输出结果如下: |
第85行: |
第34行: |
|
| |
|
| feed.</div> | | feed.</div> |
|
| |
| There are three [[WordPress:Template Tags|template tags]] used in the ''post meta data''.
| |
|
| |
| One, <tt>[[WordPress:Template Tags/the_time|the_time()]]</tt>, is used twice with different
| |
|
| |
| results. The other two tags get the information about the categories and the link to the
| |
|
| |
| RSS feed from the database.
| |
|
| |
|
| 在''文章 meta数据''中有3种[[WordPress:Template Tags|模板标签]]可以使用,第一,<tt> | | 在''文章 meta数据''中有3种[[WordPress:Template Tags|模板标签]]可以使用,第一,<tt> |
第100行: |
第41行: |
| 得到关于分类的信息和从数据库到RSS feed的连接。 | | 得到关于分类的信息和从数据库到RSS feed的连接。 |
|
| |
|
| The template tag for <tt>the_time()</tt> can be set up with a variety of parameters to tell
| |
|
| |
| the time and date of the post from information drawn from the database. In the first usage,
| |
|
| |
| the parameters <tt>l, F jS, Y</tt> pull the post's date into a format that gives the
| |
|
| |
| ''weekday, month, date,'' and ''year''. In the second usage, there are no parameters,
| |
|
| |
| therefore it just returns the time when the post was saved. You will experiment with these
| |
|
| |
| below in [[WordPress:#Changing the Time and Date|Changing the Time and Date]].
| |
|
| |
|
| <tt>the_time()</tt>的模板标签有很多显示数据库中的文章时间和日期的参数可以设置。第一种用法, | | <tt>the_time()</tt>的模板标签有很多显示数据库中的文章时间和日期的参数可以设置。第一种用法, |
第116行: |
第46行: |
| <tt>l, F jS, Y</tt>参数,把文章的日期设置成一个''周日, 月, 日,'' and ''年''的格式,第二种用 | | <tt>l, F jS, Y</tt>参数,把文章的日期设置成一个''周日, 月, 日,'' and ''年''的格式,第二种用 |
|
| |
|
| 法,没有任何参数,这样它只是返回文章是什么时候保存的值。你在下面的[[WordPress:#Changing the | | 法,没有任何参数,这样它只是返回文章是什么时候保存的值。你在下面的[[#WordPress:Changing the |
|
| |
|
| Time and Date|更改时间和日期]]中就会体会到。 | | Time and Date|更改时间和日期]]中就会体会到。 |
|
| |
|
| The template tag <tt>[[WordPress:Template Tags/the_category|the_category()]]</tt> displays
| |
|
| |
| the [[WordPress:Glossary#Category|categories]] that the post belongs to. This template tag
| |
|
| |
| can be modified to feature different text, graphics and symbols between the graphics, and
| |
|
| |
| may even use a plugin to display graphics in place of the words. There are many ways to
| |
|
| |
| style these. In this example, the [[WordPress:Glossary#Category|categories]] are listed with
| |
|
| |
| a [[WordPress:Separating_Categories|comma to separate them]].
| |
|
| |
|
| 模板标签<tt>[[WordPress:Template Tags/the_category|the_category()]]</tt>显示文章所属的 | | 模板标签<tt>[[WordPress:Template Tags/the_category|the_category()]]</tt>显示文章所属的 |
第139行: |
第58行: |
|
| |
|
| [[WordPress:Glossary#Category|分类]][[WordPress:Separating_Categories|使用逗号分开它们]]。 | | [[WordPress:Glossary#Category|分类]][[WordPress:Separating_Categories|使用逗号分开它们]]。 |
|
| |
| The last tag is the <tt>[[WordPress:Template Tags/comments_rss_link|comments_rss_link()]]
| |
|
| |
| </tt> which uses the parameter <tt>RSS 2.0</tt> to identify the type of
| |
|
| |
| [[WordPress:WordPress Feeds|feed]] being used. You can also [[WordPress:Customizing
| |
|
| |
| Feeds|customize the feed tag]], changing the way it displays the link information about the
| |
|
| |
| feed and type, or even have it feature feed icons instead of text.
| |
|
| |
|
| 最后一个标签是<tt>[[WordPress:Template Tags/comments_rss_link|comments_rss_link()]]</tt>,使 | | 最后一个标签是<tt>[[WordPress:Template Tags/comments_rss_link|comments_rss_link()]]</tt>,使 |
第157行: |
第66行: |
|
| |
|
| 或者使用feed图标来代替文本。 | | 或者使用feed图标来代替文本。 |
|
| |
| ==Changing the Text==
| |
|
| |
| Let's start to rearrange your ''post meta data'' with small steps. The first step is to
| |
|
| |
| change the text but not the tags. After all, this is your website and you want it to say
| |
|
| |
| things ''your way'', right? This example makes the ''post meta data'' a little more
| |
|
| |
| conversational:
| |
|
| |
| <pre><small>I slaved away at the computer on <?php the_time('l, F jS, Y') ?>
| |
| at the ridiculous time of <?php the_time() ?> when I could have
| |
| been doing something much more productive. I slapped this
| |
| thing into the <?php the_category(' and ') ?> 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
| |
| <?php comments_rss_link('RSS 2.0'); ?> feed, but I
| |
| wouldn't bother. No one else who reads this babble has
| |
| anything worthwhile to say.</small></pre>
| |
|
| |
|
| ==更改文本== | | ==更改文本== |
第195行: |
第83行: |
| wouldn't bother. No one else who reads this babble has | | wouldn't bother. No one else who reads this babble has |
| anything worthwhile to say.</small></pre> | | anything worthwhile to say.</small></pre> |
|
| |
| This would result in:
| |
|
| |
| <div style="border:1px solid #afafca; margin: 10px; padding:20px">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:#Changing the Text|WordPress Lessons]] and [[WordPress:#Changing the Text|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 [[WordPress:#Changing the Text|RSS 2.0]] feed, but I wouldn't bother. No one
| |
|
| |
| else who reads this babble has anything worthwhile to say.</div>
| |
|
| |
|
| 显示结果如下: | | 显示结果如下: |
第231行: |
第101行: |
|
| |
|
| else who reads this babble has anything worthwhile to say.</div> | | else who reads this babble has anything worthwhile to say.</div> |
|
| |
| Okay, there is a small change. Did you catch it?
| |
|
| |
| The usage of <tt>the_category()</tt> template tag, the parameter that sets the
| |
|
| |
| [[WordPress:Separating_Categories|separator between the list of categories]] where the post
| |
|
| |
| belongs, was changed from a '''comma (,)''' to the word '''"and"'''. It makes more sense in
| |
|
| |
| this situation.
| |
|
| |
|
| 好了,有一点小的变化,你发现了吗? | | 好了,有一点小的变化,你发现了吗? |
第247行: |
第107行: |
|
| |
|
| 器]]的参数,文章所在的地方,从一个'''逗号 (,)'''更改为单词'''"and"''',这样它更加有意义了。 | | 器]]的参数,文章所在的地方,从一个'''逗号 (,)'''更改为单词'''"and"''',这样它更加有意义了。 |
|
| |
| Now, you can also cut the chatter and make your ''post meta data'' short and sweet:
| |
|
| |
| <pre>POSTED: <?php the_time('m/j/y g:i A') ?><br />
| |
| FILED AS: <?php the_category(', ') ?><br />
| |
| COMMENTS FEED: <?php comments_rss_link('RSS 2.0'); ?></pre>
| |
|
| |
|
| 现在可以中断一下,让你的''文章 meta数据''更短,更有味道: | | 现在可以中断一下,让你的''文章 meta数据''更短,更有味道: |
第259行: |
第113行: |
| FILED AS: <?php the_category(', ') ?><br /> | | FILED AS: <?php the_category(', ') ?><br /> |
| COMMENTS FEED: <?php comments_rss_link('RSS 2.0'); ?></pre> | | COMMENTS FEED: <?php comments_rss_link('RSS 2.0'); ?></pre> |
|
| |
| Here is a very short list of your ''post meta data'':
| |
|
| |
| <div style="border:1px solid #afafca; margin: 10px; width: 50%; padding:20px">POSTED:
| |
|
| |
| 05/12/04 9:35 AM
| |
| FILED AS: [[WordPress:#Changing the Text|News]], [[WordPress:#Changing the Text|Answers]]
| |
| COMMENTS FEED: [[WordPress:#Changing the Text|RSS 2.0]]</div>
| |
|
| |
|
| 这是你的''文章 meta数据''中很短的一个列表: | | 这是你的''文章 meta数据''中很短的一个列表: |
第275行: |
第121行: |
| FILED AS: [[WordPress:#Changing the Text|News]], [[WordPress:#Changing the Text|Answers]] | | FILED AS: [[WordPress:#Changing the Text|News]], [[WordPress:#Changing the Text|Answers]] |
| COMMENTS FEED: [[WordPress:#Changing the Text|RSS 2.0]]</div> | | COMMENTS FEED: [[WordPress:#Changing the Text|RSS 2.0]]</div> |
|
| |
| ==Changing the Time and Date==
| |
|
| |
| There are many ways to change the time and date within your ''post meta data'' to reflect a
| |
|
| |
| more appropriate use for your website or your cultural timekeeping methods. For example, in
| |
|
| |
| much of the world, the date is not ''month day, year'' but ''day month year''. In the
| |
|
| |
| ''post meta data'', you would change the template tag <tt>[[WordPress:Template
| |
|
| |
| Tags/the_time|the_time()]]</tt> so the paramters would show "Monday, 21 February 2005":
| |
|
| |
| <?php the_time('1, jS F Y') ?>
| |
|
| |
|
|
| |
|
第302行: |
第134行: |
|
| |
|
| <?php the_time('1, jS F Y') ?> | | <?php the_time('1, jS F Y') ?> |
|
| |
| To add more interesting information to your ''post meta data'' there are several
| |
|
| |
| [[WordPress:Glossary#Plugin|plugins]] available which generate the date the post was last
| |
|
| |
| modified. Two such ''plugins'' are [http://guff.szub.net/2005/02/22/post-updated/ Kaf
| |
|
| |
| Oseo's Post Updated] and [http://dev.wp-plugins.org/browser/last-modified/trunk/ Nick
| |
|
| |
| Momrik's Last Modified]. In the following example, using various ways of
| |
|
| |
| [[WordPress:Formatting_Date_and_Time|manipulating time]] with PHP tags, we'll add Nick
| |
|
| |
| Momrik's ''plugin'' to the mix, <tt>mdv_last_modified()</tt>:
| |
|
| |
| <pre><div class="postmetadata">This post was written on what I
| |
| think was a <?php the_time('l'); ?>, but I know it was
| |
| the <?php the_time('jS'); ?> day in the month
| |
| of <?php the_time('F'); ?> in the year of
| |
| <?php the_time('Y'); ?>, though I messed around
| |
| with this on the <?php mdv_last_modified('dS'); ?> day
| |
| of <?php mdv_last_modified('F'); ?> in
| |
| <?php mdv_last_modified('Y'); ?>, a not-so-busy
| |
| <?php mdv_last_modified('l'); ?> when I had nothing
| |
| better to do.</p></div></pre>
| |
|
| |
|
| 想加入更多有趣的信息到''文章 meta数据''中,有几种插件可以使用,它们可以得到文章最后更改的时 | | 想加入更多有趣的信息到''文章 meta数据''中,有几种插件可以使用,它们可以得到文章最后更改的时 |
第348行: |
第155行: |
| <?php mdv_last_modified('l'); ?> when I had nothing | | <?php mdv_last_modified('l'); ?> when I had nothing |
| better to do.</p></div></pre> | | better to do.</p></div></pre> |
|
| |
| Which would result in:
| |
|
| |
| <div style="border:1px solid #afafca; margin: 10px; padding:20px">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.</div>
| |
|
| |
|
| 显示结果如下: | | 显示结果如下: |
第368行: |
第165行: |
|
| |
|
| busy Thursday when I had nothing better to do.</div> | | busy Thursday when I had nothing better to do.</div> |
|
| |
| == Adding Template Tags ==
| |
|
| |
| So far, you've covered only three of the many template tags you can add to your ''post meta
| |
|
| |
| data''. You can add the <tt>[[WordPress:Template Tags/the_title|the_title()]]</tt> to get
| |
|
| |
| the title of the post. If you want the author's name, you can add <tt>[[WordPress:Template
| |
|
| |
| Tags/the_author|the_author()]]</tt> and even the author's email with <tt>
| |
|
| |
| [[WordPress:Template Tags/the_author_email|the_author_email()]]</tt>. Want a link to all the
| |
|
| |
| posts written by a specific author? That can be arranged with the <tt>[[WordPress:Template
| |
|
| |
| Tags/the_author_posts_link|the_author_posts_link()]]</tt>.
| |
|
| |
|
| == 添加模板标签 == | | == 添加模板标签 == |
第398行: |
第179行: |
|
| |
|
| ags/the_author_posts_link|the_author_posts_link()]]</tt>来安排妥当。 | | ags/the_author_posts_link|the_author_posts_link()]]</tt>来安排妥当。 |
|
| |
| What if you want to include more basic information like the title of the website using <tt>
| |
|
| |
| [[WordPress:Template Tags/bloginfo|bloginfo()]]</tt>, or
| |
|
| |
| [[WordPress:Next_and_Previous_Links|navigation help]] like the <tt>[[WordPress:Template
| |
|
| |
| Tags/previous_post|previous_post()]]</tt> and <tt>[[WordPress:Template
| |
|
| |
| Tags/next_post|next_post()]]</tt>? We're using the next and previous post template tags to
| |
|
| |
| list posts within the same category, available to users of WordPress 1.5.1.3+. These are
| |
|
| |
| just a few examples of the many possible uses of template tags in your ''post meta data''
| |
|
| |
|
| 如果你想包括更基本的信息比如网站使用的标题,使用<tt>[[WordPress:Template | | 如果你想包括更基本的信息比如网站使用的标题,使用<tt>[[WordPress:Template |
第425行: |
第192行: |
| 例子。 | | 例子。 |
|
| |
|
| In the most simplest of usages, the ''post meta data'' could be listed as:
| |
|
| |
| <pre>POST TITLE: <?php the_title(); ?><br />
| |
| AUTHOR: <?php the_author(); ?><br />
| |
| POSTED: <?php the_time('jS F Y') ?><br />
| |
| FILED AS: <?php the_category(', ') ?><br />
| |
| COMMENT FEED: <?php comments_rss_link('RSS 2.0'); ?><br />
| |
| PREVIOUS: <?php previous_post('%', '', 'yes', 'yes'); ?><br />
| |
| NEXT: <?php next_post('%', '', 'yes', 'yes'); ?></pre>
| |
|
| |
|
| 在最简单的用法中,''文章 meta数据''可以如下列出 | | 在最简单的用法中,''文章 meta数据''可以如下列出 |
第445行: |
第203行: |
| NEXT: <?php next_post('%', '', 'yes', 'yes'); ?></pre> | | NEXT: <?php next_post('%', '', 'yes', 'yes'); ?></pre> |
|
| |
|
| And would look like this:
| |
|
| |
| <div style="border:1px solid #afafca; width: 50%; margin: 10px; padding:20px">POST TITLE:
| |
|
| |
| [[WordPress:#Adding Template Tags|WordPress Makes Me Smile]]<br />
| |
| AUTHOR: [[WordPress:#Adding Template Tags|Harriet Smith]]<br />
| |
| POSTED: 20 April 2004<br />
| |
| FILED AS: [[WordPress:#Adding Template Tags|WordPress]], [[WordPress:#Adding Template
| |
|
| |
| Tags|News]]<br />
| |
| COMMENT FEED: [[WordPress:#Adding Template Tags|RSS 2.0]]<br />
| |
| PREVIOUS: [[WordPress:#Adding Template Tags|Things to Do With WordPress]]<br />
| |
| NEXT: [[WordPress:#Adding Template Tags|Why I Like WordPress]]</div>
| |
|
| |
|
| 显示如下: | | 显示如下: |
第472行: |
第217行: |
| PREVIOUS: [[WordPress:#Adding Template Tags|Things to Do With WordPress]]<br /> | | PREVIOUS: [[WordPress:#Adding Template Tags|Things to Do With WordPress]]<br /> |
| NEXT: [[WordPress:#Adding Template Tags|Why I Like WordPress]]</div> | | NEXT: [[WordPress:#Adding Template Tags|Why I Like WordPress]]</div> |
|
| |
| If you want this in your sidebar, and you want a more conversational style, then in your
| |
|
| |
| [[WordPress:Templates|template file]], <tt>sidebar.php</tt>, find a good spot to put the
| |
|
| |
| following:
| |
|
| |
| <pre><div class="postmetadata"><p>You are reading the article,
| |
| <?php the_title(); ?>, on our website, <?php bloginfo('name'); ?>.
| |
| This article was written on <?php the_time('jS F Y') ?>, in
| |
| Seattle, Washington, and you can find similar articles in
| |
| the <?php the_category(' and ') ?> categories, or more articles
| |
| by <?php |the_author_posts_link() ?>, if you enjoyed this article.
| |
| If you have any comments about this article, you can contact
| |
| <?php the_author() ?> by <a href="mailto:<?php the_author_email(); ?>">
| |
| email</a>, or leave a comment below. You can also follow comments
| |
| made on this article via our <?php comments_rss_link('RSS 2.0'); ?>
| |
| feed.</p>
| |
| <p>If you would like to continue reading more,
| |
| <?php previous_post('the previous article on our site is called %', ' ', 'yes', 'yes'); ?>
| |
| <?php next_post(' and the next article is called %', ' ', 'yes', 'yes'); ?>.
| |
| Thank you for visiting our site.</p></div></pre>
| |
|
| |
|
| 如果你想让这些内容显示在边栏中,而且你想要一个会话式的样式,那么在你的[[WordPress:Templates| | | 如果你想让这些内容显示在边栏中,而且你想要一个会话式的样式,那么在你的[[WordPress:Templates| |
第514行: |
第237行: |
| <?php next_post(' and the next article is called %', ' ', 'yes', 'yes'); ?>. | | <?php next_post(' and the next article is called %', ' ', 'yes', 'yes'); ?>. |
| Thank you for visiting our site.</p></div></pre> | | Thank you for visiting our site.</p></div></pre> |
|
| |
| This example, if styled in a narrow column found on most sidebars, would look like this:
| |
|
| |
| <div style="border:1px solid #afafca; width: 40%; margin: 10px; padding:20px; font-size:
| |
|
| |
| 95%">You are reading the article, [[WordPress:#Adding Template Tags|WordPress Makes Me
| |
|
| |
| Smile]], on our website, [[WordPress:#Adding Template Tags|Talking Blog]]. This article was
| |
|
| |
| written on May 15, 2004, in Seattle, Washington, and you can find similar articles in the
| |
|
| |
| [[WordPress:#Adding Template Tags|WordPress]] and [[WordPress:#Adding Template Tags|Blog]]
| |
|
| |
| categories, or more articles by [[WordPress:#Adding Template Tags|Harriet Smith]], if you
| |
|
| |
| enjoyed this article. If you have any comments about this article, you can contact Harriet
| |
|
| |
| Smith by [[WordPress:#Adding Template Tags|email]], or leave a comment below. You can also
| |
|
| |
| follow comments made on this article via our [[WordPress:#Adding Template Tags|RSS 2.0]]
| |
|
| |
| feed.
| |
|
| |
| If you would like to continue reading more, the previous article on our site is called
| |
|
| |
| [[WordPress:#Adding Template Tags|Things To Do With WordPress]] and the next article is
| |
|
| |
| called [[WordPress:#Adding Template Tags|Why I Like WordPress]]. Thank you for visiting our
| |
|
| |
| site.</div>
| |
|
| |
|
| 这个例子如果被规划在一个大多数边栏的窄栏目中,将显示如下: | | 这个例子如果被规划在一个大多数边栏的窄栏目中,将显示如下: |
第574行: |
第267行: |
|
| |
|
| site.</div> | | site.</div> |
|
| |
| This is just the beginning. There are many ways you can
| |
|
| |
| [[WordPress:Blog_Design_and_Layout|style your ''post meta data'']]; by putting it in a box,
| |
|
| |
| by making it part of the text, by having it in a list...it's up to your imagination how you
| |
|
| |
| want to style your ''post meta data'', and what information you want to share with your
| |
|
| |
| public about your posts.
| |
|
| |
|
| 这只是开始,有很多[[WordPress:Blog_Design_and_Layout|设计你的''文章 meta数据'']]的方法:通过 | | 这只是开始,有很多[[WordPress:Blog_Design_and_Layout|设计你的''文章 meta数据'']]的方法:通过 |
|
| |
|
| 把它放入文本框,把它变为文本的一部分,把它在列表中列出等等。这都取决于你的希望如何设计你的''
| | 把它放入文本框,把它变为文本的一部分,把它在列表中列出等等。这都取决于你希望如何设计你的'' |
|
| |
|
| 文章 meta数据'',和你想通过你的文章分享什么样的信息。 | | 文章 meta数据'',和你想通过你的文章分享什么样的信息。 |
|
| |
|
| ==More Resources==
| |
|
| |
| * [[WordPress:Stepping Into Template Tags]]
| |
| * [[WordPress:Formatting Date and Time]]
| |
| * [[WordPress:Separating Categories]]
| |
| * [[WordPress:Template Tags]]
| |
| * [[WordPress:Styling Lists with CSS]]
| |
| * [[WordPress:Good Navigation Links]]
| |
| * [[WordPress:Next and Previous Links]]
| |
| * [[WordPress:WordPress Feeds]]
| |
|
| |
|
| ==更多资源== | | ==更多资源== |
文章 meta数据是提供给访问者的每个文章的"管理的"信息。这个
信息通常包括作者、写(或是发布)的时间和作者如何分类这篇文章。
这一课将告诉你一些改变主题设计,使用你想要的方法来显示这些重要信息的方法。
在很多情况下,文章 meta数据会在文章自身形成后立即形成,一些主题设计成把这些信息放在文章
顶部,别的一些主题可能会放在顶部或者底部的边栏中,还有一些写主题甚至放在页脚。基本上,文章 meta数据可以设计成不同的方式,带有不同的多种细节内容。
默认用法[ ]
默认的WordPress 主题把文章 meta数据这基本信息和标签定位在文章
下部分,在评论之前的一个信息框中。简化的代码如下:
<small>This entry was posted on
<?php the_time('l, F jS, Y') ?> at
<?php the_time() ?> and is filed
under <?php the_category(', ') ?>. You
can follow any responses to this entry
through the <?php comments_rss_link('RSS 2.0'); ?>
feed.</small>
这输出结果如下:
This
entry was posted on Monday, February 12, 2003 at 11:32 and is filed under
[[WordPress:#Default Usage|WordPress Lessons]], [[WordPress:#Default Usage|Things to Know]].
You can follow any responses to this entry though the [[WordPress:#Default Usage|RSS 2.0]]
feed.
在文章 meta数据中有3种模板标签可以使用,第一,
the_time(),使用两次带有不同的结果,另外两种标签是
得到关于分类的信息和从数据库到RSS feed的连接。
the_time()的模板标签有很多显示数据库中的文章时间和日期的参数可以设置。第一种用法,
l, F jS, Y参数,把文章的日期设置成一个周日, 月, 日, and 年的格式,第二种用
法,没有任何参数,这样它只是返回文章是什么时候保存的值。你在下面的[[#WordPress:Changing the
Time and Date|更改时间和日期]]中就会体会到。
模板标签the_category()显示文章所属的
分类。这个模板标签可以更改来适应不同的文本、图片、图片之间的
符号,还可以使用插件来代替文字显示图片。有很多种设计方法。在这个例子中列出的
分类使用逗号分开它们。
最后一个标签是comments_rss_link(),使
用参数RSS 2.0来识别使用的feed类型。你也可以
自定义feed标签,更改它的显示有关feed和模型的连接信息的方式,
或者使用feed图标来代替文本。
更改文本[ ]
让我们开始重新排版你的文章 meta数据。第一步是更改文本而不是标签。毕竟,这是你的网站,你
希望它使用你的方式来排列,对吧?这个例子让文章 meta数据更加会话式:
<small>I slaved away at the computer on <?php the_time('l, F jS, Y') ?>
at the ridiculous time of <?php the_time() ?> when I could have
been doing something much more productive. I slapped this
thing into the <?php the_category(' and ') ?> 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
<?php comments_rss_link('RSS 2.0'); ?> feed, but I
wouldn't bother. No one else who reads this babble has
anything worthwhile to say.</small>
显示结果如下:
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:#Changing the Text|WordPress Lessons]] and [[WordPress:#Changing the Text|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 [[WordPress:#Changing the Text|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: <?php the_time('m/j/y g:i A') ?><br />
FILED AS: <?php the_category(', ') ?><br />
COMMENTS FEED: <?php comments_rss_link('RSS 2.0'); ?>
这是你的文章 meta数据中很短的一个列表:
POSTED:
05/12/04 9:35 AM
FILED AS: [[WordPress:#Changing the Text|News]], [[WordPress:#Changing the Text|Answers]]
COMMENTS FEED: [[WordPress:#Changing the Text|RSS 2.0]]
更改日期和时间[ ]
文章 meta数据中有很多种方法更改时间和日期,来反映出对你的网站或者是你时间文化更合适的用
法,举个例子,世界上很多地方不是月 日, 年而是日 月, 年。在文章 meta数据中,你可
以改变the_time()模板标签,这样参数就会显
示"Monday, 21 February 2005"了:
<?php the_time('1, jS F Y') ?>
想加入更多有趣的信息到文章 meta数据中,有几种插件可以使用,它们可以得到文章最后更改的时
间。两种这样的插件是[http://guff.szub.net/2005/02/22/post-updated/ Kaf Oseo's Post
Updated] 和[http://dev.wp-plugins.org/browser/last-modified/trunk/ Nick Momrik's Last
Modified],在下边的例子中,使用manipulating time带有
PHP标签的不同方法,我们会把Nick Momrik的插件加入混合,mdv_last_modified():
<div class="postmetadata">This post was written on what I
think was a <?php the_time('l'); ?>, but I know it was
the <?php the_time('jS'); ?> day in the month
of <?php the_time('F'); ?> in the year of
<?php the_time('Y'); ?>, though I messed around
with this on the <?php mdv_last_modified('dS'); ?> day
of <?php mdv_last_modified('F'); ?> in
<?php mdv_last_modified('Y'); ?>, a not-so-busy
<?php mdv_last_modified('l'); ?> when I had nothing
better to do.</p></div>
显示结果如下:
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()以得到作者的电子邮件。想
要某个作者的所有文章的连接?可以使用[[WordPress:Template
ags/the_author_posts_link|the_author_posts_link()]]来安排妥当。
如果你想包括更基本的信息比如网站使用的标题,使用[[WordPress:Template
Tags/bloginfo|bloginfo()]]或者导航帮助如
previous_post()和[[WordPress:Template
Tags/next_post|next_post()]]?我们使用WordPress 1.5.1.3+的使用者可用的,上一个和下一个
文章模板标签来列出同一列表中的文章。这些只是文章 meta数据中很多可能的模板标签用法的几个
例子。
在最简单的用法中,文章 meta数据可以如下列出
POST TITLE: <?php the_title(); ?><br />
AUTHOR: <?php the_author(); ?><br />
POSTED: <?php the_time('jS F Y') ?><br />
FILED AS: <?php the_category(', ') ?><br />
COMMENT FEED: <?php comments_rss_link('RSS 2.0'); ?><br />
PREVIOUS: <?php previous_post('%', '', 'yes', 'yes'); ?><br />
NEXT: <?php next_post('%', '', 'yes', 'yes'); ?>
显示如下:
POST TITLE:
[[WordPress:#Adding Template Tags|WordPress Makes Me Smile]]
AUTHOR: [[WordPress:#Adding Template Tags|Harriet Smith]]
POSTED: 20 April 2004
FILED AS: [[WordPress:#Adding Template Tags|WordPress]], [[WordPress:#Adding Template
Tags|News]]
COMMENT FEED: [[WordPress:#Adding Template Tags|RSS 2.0]]
PREVIOUS: [[WordPress:#Adding Template Tags|Things to Do With WordPress]]
NEXT: [[WordPress:#Adding Template Tags|Why I Like WordPress]]
如果你想让这些内容显示在边栏中,而且你想要一个会话式的样式,那么在你的
模板文件中,sidebar.php,找一个地方输入以下内容:
<div class="postmetadata"><p>You are reading the article,
<?php the_title(); ?>, on our website, <?php bloginfo('name'); ?>.
This article was written on <?php the_time('jS F Y') ?>, in
Seattle, Washington, and you can find similar articles in
the <?php the_category(' and ') ?> categories, or more articles
by <?php |the_author_posts_link() ?>, if you enjoyed this article.
If you have any comments about this article, you can contact
<?php the_author() ?> by <a href="mailto:<?php the_author_email(); ?>">
email</a>, or leave a comment below. You can also follow comments
made on this article via our <?php comments_rss_link('RSS 2.0'); ?>
feed.</p>
<p>If you would like to continue reading more,
<?php previous_post('the previous article on our site is called %', ' ', 'yes', 'yes'); ?>
<?php next_post(' and the next article is called %', ' ', 'yes', 'yes'); ?>.
Thank you for visiting our site.</p></div>
这个例子如果被规划在一个大多数边栏的窄栏目中,将显示如下:
You are reading the article, [[WordPress:#Adding Template Tags|WordPress Makes Me
Smile]], on our website, [[WordPress:#Adding Template Tags|Talking Blog]]. This article was
written on May 15, 2004, in Seattle, Washington, and you can find similar articles in the
[[WordPress:#Adding Template Tags|WordPress]] and [[WordPress:#Adding Template Tags|Blog]]
categories, or more articles by [[WordPress:#Adding Template Tags|Harriet Smith]], if you
enjoyed this article. If you have any comments about this article, you can contact Harriet
Smith by [[WordPress:#Adding Template Tags|email]], or leave a comment below. You can also
follow comments made on this article via our [[WordPress:#Adding Template Tags|RSS 2.0]]
feed.
If you would like to continue reading more, the previous article on our site is called
[[WordPress:#Adding Template Tags|Things To Do With WordPress]] and the next article is
called [[WordPress:#Adding Template Tags|Why I Like WordPress]]. Thank you for visiting our
site.
这只是开始,有很多设计你的文章 meta数据的方法:通过
把它放入文本框,把它变为文本的一部分,把它在列表中列出等等。这都取决于你希望如何设计你的
文章 meta数据,和你想通过你的文章分享什么样的信息。
更多资源[ ]