WordPress:Template Tags/the category ID

来自站长百科
跳转至: 导航、​ 搜索

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.


描述[ ]

显示或者返回一篇文章所属的类别的ID号码。必须在The Loop内部使用这个标签。

取代[ ]

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

<?php

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

用法[ ]

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

例子[ ]

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

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

参数[ ]

echo
(boolean) 显示类别 ID (TRUE) 或者将其返回用在 PHP (FALSE).。默认TRUE.。

相关的[ ]

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