WordPress:Separating Categories

来自站长百科
Seadragon530讨论 | 贡献2008年4月15日 (二) 11:08的版本
跳转至: 导航、​ 搜索

Your posts are filed in different categories. Category information is freqently displayed in the post meta data section near your post or under the heading title. Different WordPress Themes highlight the post meta data section in different areas.

你的文章是用不同分类存档的。分类信息通常显示在文章附近的文章 meta 数据部分或者是在头部标题下面。不同的WordPress 主题会在不同的区域高亮显示文章meta信息部分。

The display of the post categories is generated through the use of the the_category() template tag. And you have the ability to style how these categories are displayed.

文章分类的显示是通过the_category()模板标签的使用来生成的。你可以设计这些分类如何显示。

Finding Your Categories Tag

The placement of your categories tag may be in one place on the front page and in one or more different places in your single post page, so you may have to do some hunting to find your various categories tags. You might also want to style one differently from the others, but you still have to find them.

找出分类标签

你的分类标签可能放在首页面,也可能放在一个或多个单独文章页面的不同地方,这样你可能不得不费点力气来寻找你不同的分类标签了。你可能还想设计一个与众不同的标签,但首先要把它们找出来。

The post meta data featuring your categories tag in your Theme is usually found on the index.php, single.php, or sometimes in the sidebar.php template files. Open one or more of these template files and search for:

<?php the_category() ?>

在整个主题中,带有你的分类标签的文章 meta 数据,通常可以在index.php, single.php,或者有时在sidebar.php 模板文件中可以找到。打开一个或者多个模板文件并搜索:

<?php the_category() ?>

Once you have found it, take another look at a generated web page of your site and determine how exactly you might want to change this information.

一旦找到之后,再看看网页,然后决定如何更改这些信息。

The the_category() template tag instructs the database to get the information regarding the post categories and display it at that point in your template file. By default, it displays the list of categories with a space between each one. You can change this by adding the parameter inside of the tag. Let's begin with simple separators by playing with the category names: WordPress, Computers, and Internet News.

the_category()模板标签指导数据库获得关于文章分类的信息,并且在模板文件中显示出来。默认情况下,它显示分类的列表,每两个分类中间有空格隔开。你可以通过添加标签内部的参数更改它们。让我们通过分类名:WordPress, Computers, and Internet News,从简单的分隔器开始。

Simple Separators

If you would like to have commas between the categories, the tag should read:

<?php the_category(',') ?>

简单的分隔器

如果你想在分类中间加上逗号,标签内容如下:

<?php the_category(',') ?>

And it would look like this:

WordPress, Computers, Internet News

显示结果如下:

WordPress, Computers, Internet News

If you would like to have an arrow, the tag would look like this:

<?php the_category(' > ') ?>
WordPress > Computers > Internet News

如果你还想要有一个箭头,标签内容如下

<?php the_category(' > ') ?>
WordPress > Computers > Internet News

If you would like to have a bullet, the tag would look like this:

<?php the_category(' &bull; ') ?>
WordPress • Computers • Internet News

如果你想有一个bullet符号,标签内容如下:

<?php the_category(' &bull; ') ?>
WordPress • Computers • Internet News

If you would like the "pipe" ( | ) between the categories, the tag would look like this:

<?php the_category(' | ') ?>
WordPress | Computers | Internet News

如果你想要在分类中间加入"pipe" ( | )符号,这个标签内容如下:

<?php the_category(' | ') ?>
WordPress | Computers | Internet News


Adding Text to Your Categories

Would you like to make your post meta data look a little more textual, informal and part of a paragraph rather than a list. You can add an "and" to go between the categories like this:

<p>You can read related subjects in 
the <?php the_category(' and ') ?> categories.</p>
You can read related subjects in the WordPress and Computers and Internet News categories.

向分类中添加文本

你想让你的文章meta数据看起来更象文字,非正式并且象是一段文章而不是列表吗?你可以在分类中间加入"and",如下:

<p>You can read related subjects in 
the <?php the_category(' and ') ?> categories.</p>
You can read related subjects in the WordPress and Computers and Internet News categories.

Or you can give them more of a choice and change the "and" to an "or":

You can read related subjects in the WordPress or Computers or Internet News categories.

或者你可以给它们更多的选择,把"and" 改成"or":

You can read related subjects in the WordPress or Computers or Internet News categories.

The possibilities are endless. Have fun and use your imagination! 可能性是无限的。运用你的想象力,玩的开心!