Codex tools: Log in / create account
Contents |
Retrieve the ID of a category from its name.
<?php get_cat_ID( $cat_name ) ?>
This is a very basic example of how to use this function in 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;
?>
Since: 1.0.0
get_cat_ID() is located in wp-includes/category.php.