常用函数-get_cat_ID()

1条评论

常用函数-get_cat_ID()

说明

按名称检索类别编号。

用法

<?php get_cat_ID( $cat_name ) ?>

参数

$cat_name

(字符)(可选)默认值为"General",可以是任何类别名称。

默认值:'General'

返回的值

(整数)

出错时返回0,成功则返回类别编号。

示例

基本示例

以下是在 The_Loop(循环)中使用该函数的基本示例。

<?php       
    $category_id = get_cat_id('Category Name');       
    $q = 'cat=' . $category_id;       
    query_posts($q);       
    if (have_posts()) : while (have_posts()) : the_post();         

    the_content();         

    endwhile; endif;  
?>  

注释

修改记录

自1.1.0版本后

源文件

get_cat_ID() 位于 wp-includes/category.php中。

相关资源

#1
http://www.chooseinsurers.net/|pa health insurance 8)) http://www.getedmeds.com/|levitra cialis nus

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 允许HTML标签:<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • 自动断行和分段。

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.