WordPress:Template Tags/the category ID

来自站长百科
Fludlen讨论 | 贡献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