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

来自站长百科
跳转至: 导航、​ 搜索
(新页面: {{Deprecated}} == Description == Displays or returns the numeric ID of the category a post belongs to. This tag must be used within WordPress:The Loop. == Replace With == This tag w...)
 
无编辑摘要
第1行: 第1行:
{{Deprecated}}
{{Deprecated}}
{{取消的}}
== Description ==
== Description ==
== 描述 ==
Displays or returns the numeric ID of the category a post belongs to. This tag must be used within [[WordPress:The Loop]].
Displays or returns the numeric ID of the category a post belongs to. This tag must be used within [[WordPress:The Loop]].
显示或者返回一篇文章所属的类别的ID号码。必须在[[WordPress:The Loop|The Loop]]内部使用这个标签。


== Replace With ==
== Replace With ==
== 取代 ==


This tag was deprecated when multiple categories were added to WordPress, and there is no one-to-one correspondence with another tag. This PHP code block provides an example for how you can replace it:
This tag was deprecated when multiple categories were added to WordPress, and there is no one-to-one correspondence with another tag. This PHP code block provides an example for how you can replace it:
当多个类别添加到WordPress上的时候,这个标签便被取消了,而且没有一对一的对等标签。PHP编码块提供了一个例子,关于怎样替代这个标签:


  <?php  
  <?php  
foreach((get_the_category()) as $category) {
    echo $category->cat_ID . ' ';
} ?>
<?php
  foreach((get_the_category()) as $category) {  
  foreach((get_the_category()) as $category) {  
     echo $category->cat_ID . ' ';  
     echo $category->cat_ID . ' ';  
第13行: 第26行:


== Usage ==
== Usage ==
== 用法 ==


%%% <?php the_category_ID(echo); ?> %%%
%%% <?php the_category_ID(echo); ?> %%%
%%% <?php the_类别_ID(echo); ?> %%%


== Example ==
== Example ==
== 例子 ==


Displays a corresponding image for each category.
Displays a corresponding image for each category.
为每个类别显示一个相应的图像。


  <img src="<?php the_category_ID(); ?>.gif" />
  <img src="<?php the_category_ID(); ?>.gif" />


<img src="<?php the_category_ID(); ?>.gif" />
== Parameters ==
== Parameters ==
== 参数 ==


; echo : (''boolean'') Display the category ID (<tt>TRUE</tt>) or return it for use in PHP (<tt>FALSE</tt>). Defaults to <tt>TRUE</tt>.  
; echo : (''boolean'') Display the category ID (<tt>TRUE</tt>) or return it for use in PHP (<tt>FALSE</tt>). Defaults to <tt>TRUE</tt>.  
; echo : (''boolean'') 显示类别 ID (<tt>真的</tt>) 或者将其返回用在 PHP (<tt>错误的</tt>).。默认<tt>真确的</tt>.。


== Related ==
== Related ==
第31行: 第57行:


{{Tag Footer}}
{{Tag Footer}}
== 相关的==
{{标签 类别标签}}
{{标签 页底文字}}

2008年6月28日 (六) 17:07的版本

模板:Deprecated


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.


Description

描述

Displays or returns the numeric ID of the category a post belongs to. This tag must be used within WordPress:The Loop.

显示或者返回一篇文章所属的类别的ID号码。必须在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. This PHP code block provides an example for how you can replace it:

当多个类别添加到WordPress上的时候,这个标签便被取消了,而且没有一对一的对等标签。PHP编码块提供了一个例子,关于怎样替代这个标签:

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

<?php

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

Usage

用法

%%% <?php the_category_ID(echo); ?> %%%

%%% <?php the_类别_ID(echo); ?> %%%

Example

例子

Displays a corresponding image for each category.

为每个类别显示一个相应的图像。

<img src="<?php the_category_ID(); ?>.gif" />

<img src="<?php the_category_ID(); ?>.gif" />

Parameters

参数

echo
(boolean) Display the category ID (TRUE) or return it for use in PHP (FALSE). Defaults to TRUE.
echo
(boolean) 显示类别 ID (真的) 或者将其返回用在 PHP (错误的).。默认真确的.。

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,

模板:Tag Footer

相关的

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