WordPress: Template Tags/the category head:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
无编辑摘要
无编辑摘要
第1行: 第1行:
{{Deprecated}}
== Description ==
{{取消的}}
{{取消的}}
==描述 ==
==描述 ==
Displays the name of a category if it's different from the previous category. This tag must be used within [[WordPress:The Loop]].


如果类别与前一个类别不同,就要显示这个类别名。必须在[[WordPress:The Loop|The Loop]]内部使用这个标签。
如果类别与前一个类别不同,就要显示这个类别名。必须在[[WordPress:The Loop|The Loop]]内部使用这个标签。
== Replace With ==


== 取代 ==
== 取代 ==
This tag was deprecated when multiple categories were added to WordPress, and there is no one-to-one correspondence with another tag.


当WordPress中添加多个类别的时候,这个标签就被取消了,而且没有一对一的对等标签。
当WordPress中添加多个类别的时候,这个标签就被取消了,而且没有一对一的对等标签。
To display the name of the category when on a category page, use:


要在一个类别网页上显示类别名,请使用:
要在一个类别网页上显示类别名,请使用:
<?php echo get_the_category_by_ID($cat); ?>


<?php echo get_the_category_by_ID($cat); ?>
<?php echo get_the_category_by_ID($cat); ?>
To display category name(s) on a single post page, this code block (which would need to run in [[WordPress:The Loop]]) provides an example:


要在一个单独的文章网页上显示类别名,这个代码块(需要运行[[WordPress:The Loop|The Loop]])提供了一个例子:
要在一个单独的文章网页上显示类别名,这个代码块(需要运行[[WordPress:The Loop|The Loop]])提供了一个例子:
<?php
foreach(get_the_category() as $category) {
    echo $category->cat_name . ' ';
}
?>


<?php
<?php
第41行: 第20行:
  ?>
  ?>


== Usage ==


== 用法 ==
== 用法 ==


%%% <?php the_category_head('before', 'after'); ?> %%%
%%% <?php the_category_head('before', 'after'); ?> %%%
%%% <?php the_类别_标头('之前', '之后'); ?> %%%
== Example ==


== 例子 ==
== 例子 ==


Displays the text "'''Category: '''" followed by the name of the category.
在类别名之前显示文本"'''Category: '''"。
 
在类别名之前显示文本"'''类别: '''"。


  &lt;h2&gt;<?php the_category_head('Category: '); ?>&lt;/h2&gt;
  &lt;h2&gt;<?php the_category_head('Category: '); ?>&lt;/h2&gt;
&lt;h2&gt;<?php the_类别_标头('类别: '); ?>&lt;/h2&gt;
== Parameters ==


== 参数 ==
== 参数 ==


; before : (''string'') Text to output before the category. Defaults to <tt>&#39;&#39;</tt> (no text).
; before: (''string'') 类别之前的文本。默认T <tt>&#39;&#39;</tt> (没有文本)。
; after : (''string'') Text to output after the category. Defaults to <tt>&#39;&#39;</tt> (no text).
;after : (''string'') 类别之后的文本。默认<tt>&#39;&#39;</tt> (没有文本)。
 
; 之前 : (''string'') 类别之前的文本。默认T <tt>&#39;&#39;</tt> (没有文本)。
; 之后 : (''string'') 类别之后的文本。默认<tt>&#39;&#39;</tt> (没有文本)。
 
== Related ==
 
{{Tag Category Tags}}
 
{{PHP Function Tag Footer}}
 


== 相关的 ==
== 相关的 ==

2008年7月5日 (六) 17:37的版本


This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement if one exists.


描述

如果类别与前一个类别不同,就要显示这个类别名。必须在The Loop内部使用这个标签。

取代

当WordPress中添加多个类别的时候,这个标签就被取消了,而且没有一对一的对等标签。

要在一个类别网页上显示类别名,请使用:

<?php echo get_the_category_by_ID($cat); ?>

要在一个单独的文章网页上显示类别名,这个代码块(需要运行The Loop)提供了一个例子:

<?php

foreach(get_the_category() as $category) {
    echo $category->cat_name . ' '; 
}
?>


用法

%%% <?php the_category_head('before', 'after'); ?> %%%

例子

在类别名之前显示文本"Category: "。

<h2><?php the_category_head('Category: '); ?></h2>

参数

before
(string) 类别之前的文本。默认T '' (没有文本)。
after
(string) 类别之后的文本。默认'' (没有文本)。

相关的

模板:标签类别标签

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