WordPress: Function Reference/get category link:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
(新页面: == Description == Returns the correct url for a given Category ID. This is a category id of blog posts, not links. Using a nonexistent Category ID will return a link to the parent direc...)
 
无编辑摘要
第1行: 第1行:
== Description ==
== Description ==
== 描述 ==
Returns the correct url for a given Category ID.
Returns the correct url for a given Category ID.
为一个特定的类别ID返回正确的url。


This is a category id of blog posts, not links.
This is a category id of blog posts, not links.
这是博客文章的一个类别id,而不是链接。


Using a nonexistent Category ID will return a link to the parent directory
Using a nonexistent Category ID will return a link to the parent directory
使用不存在的ID会返回一个链接,链接到母目录


eg: http://yoursite.com/baseurl/archives/category/
eg: http://yoursite.com/baseurl/archives/category/
例子: http://yoursite.com/baseurl/archives/category/


== Usage ==
== Usage ==
== 用法 ==
<code><a href="</code>%%%<?php echo get_category_link($cat);?>%%%<code>">category name</a></code>
<code><a href="</code>%%%<?php echo get_category_link($cat);?>%%%<code>">category name</a></code>
<code><a href="</code>%%%<?php echo get_category_link($cat);?>%%%<code>">类别 名</a></code>


== Parameters ==
== Parameters ==
== 参数 ==
{{Parameter|$category_id|integer|The category ID whose link will be retrieved.}}
{{Parameter|$category_id|integer|The category ID whose link will be retrieved.}}
{{Parameter|$category_id|integer|链接能够重新找回的类别ID。}}


== Related ==
== Related ==
第21行: 第37行:


[[WordPress:Category:Functions]]
[[WordPress:Category:Functions]]
{{Copyedit}}
== 相关的 ==
{{标签 类别 标签}}
{{PHP 函数 标签 页底文字}}
[[WordPress:Category:Functions|类别:函数]]


{{Copyedit}}
{{Copyedit}}

2008年7月1日 (二) 16:22的版本

Description

描述

Returns the correct url for a given Category ID.

为一个特定的类别ID返回正确的url。

This is a category id of blog posts, not links.

这是博客文章的一个类别id,而不是链接。

Using a nonexistent Category ID will return a link to the parent directory

使用不存在的ID会返回一个链接,链接到母目录

eg: http://yoursite.com/baseurl/archives/category/

例子: http://yoursite.com/baseurl/archives/category/

Usage

用法

<a href="%%%<?php echo get_category_link($cat);?>%%%">category name</a>

<a href="%%%<?php echo get_category_link($cat);?>%%%">类别 名</a>

Parameters

参数

Related

the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category, get_category_parents, get_the_category get_category_link,

模板:PHP Function Tag Footer

WordPress:Category:Functions

This article is [[WordPress::Category:Copyedits|marked]] as in need of editing. You can help Codex by editing it.

相关的

Description

描述

Displays a link to the category or categories a post belongs to. This tag must be used within WordPress:The Loop.

显示文章所属的类别的连接。必须在The Loop内,使用这个标签。

Usage

用法

%%% <?php the_category('separator', 'parents' ); ?> %%% %%% <?php the_category('separator', 'parents' ); ?> %%%

Examples

Separated by Space

例子

由空格分开

This usage lists categories with a space as the separator.

这个用法用分隔符,隔开类别,列出。

<p>Categories: <?php the_category(' '); ?></p>
<p>Categories: <?php the_category(' '); ?></p>
Categories: [[WordPress:#Examples|WordPress]] [[WordPress:#Examples|Computers]] [[WordPress:#Examples|Blogging]]
类别: [[WordPress:#Examples|WordPress]] [[WordPress:#Examples|电脑]] [[WordPress:#Examples|写博客]]

Separated by Comma

用逗号分开

Displays links to categories, each category separated by a comma (if more than one).

显示类别连接,(如果多于一个类别)类别之间用逗号分开。

<p>This post is in: <?php the_category(', '); ?></p>

<p>This post is in: <?php the_category(', '); ?></p>

This post is in: [[WordPress:#Examples|WordPress]], [[WordPress:#Examples|Computers]], [[WordPress:#Examples|Blogging]]


This post is in: [[WordPress:#Examples|WordPress]], [[WordPress:#Examples|电脑]], [[WordPress:#Examples|写博客]]


Separated by Arrow

用箭头分开

Displays links to categories with an arrow (>) separating the categories. (Note: Take care when using this, since some viewers may interpret a category following a > as a subcategory of the one preceding it.)

用箭头显示类别链接(>)分开类别。(注: 使用这种方法的时候,应该注意,有的访客认为类别后面的> 是前面类别的子类别。)

<p>Categories: <?php the_category(' &gt; '); ?></p>

<p>Categories: <?php the_category(' &gt; '); ?></p>

Categories: [[WordPress:#Examples|WordPress]] > [[WordPress:#Examples|Computers]] > [[WordPress:#Examples|Blogging]]
类别: [[WordPress:#Examples|WordPress]] > [[WordPress:#Examples|电脑]] > [[WordPress:#Examples|写博客]]

Separated by a Bullet

用Bullet分开

Displays links to categories with a bullet (•) separating the categories.

使用bullet (•)分开类别,显示类别链接

%%%

Post Categories: <?php the_category(' &bull; '); ?>

%%% %%%

文章类别: <?php the_category(' &bull; '); ?>

%%%

Post Categories: [[WordPress:#Examples|WordPress]] • [[WordPress:#Examples|Computers]] • [[WordPress:#Examples|Blogging]]
文章类别: [[WordPress:#Examples|WordPress]] • [[WordPress:#Examples|电脑]] • [[WordPress:#Examples|写博客]]

Parameters

参数

separator
(string) Text or character to display between each category link. The default is to place the links in an unordered list.

;分隔符: (string)链接类别之间显示的文本或者字符。默认是将链接放在无序列表上。

parents
(string) How to display links that reside in child (sub) categories. Options are:
parents
(string)怎样显示子类别中的链接。选项有:
  • 'multiple' - Display separate links to parent and child categories, exhibiting "parent/child" relationship.
  • 'multiple' -分开显示母类别和子类别的链接,显示为"母/子"关系。
  • 'single' - Display link to child category only, with link text exhibiting "parent/child" relationship.
  • 'single' -只显示子类别链接,链接文本显示为"母/子"关系。
Note: Default is a link to the child category, with no relationship exhibited.

:注:默认是链接到子类别的一个链接,不显示关系。

Related

the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, in_category, get_category_parents, get_the_category get_category_link,

模板:PHP Function Tag Footer


相关的

模板:标签类别标签

模板:PHP 函数标签页底文字

模板:PHP 函数 标签 页底文字

类别:函数

This article is [[WordPress::Category:Copyedits|marked]] as in need of editing. You can help Codex by editing it.