[wp-pro] Re: in_category() help

Tom Ransom lists at 1bigidea.com
Tue Nov 11 01:08:27 GMT 2008


$category = get_category_by_slug ('SLUGNAME') (since 2.3) - return  
category object
$catid = $category->term_id;

or

$featured_catid = $wpdb->get_var("SELECT term_id FROM $wpdb->terms  
WHERE slug='SLUGNAME'");

- Tom Ransom


On Nov 10, 2008, at 4:22 PM, Daniel Cameron wrote:

>
> Anyone know how I can query for a cat_ID off a category_nicename?
>
> I'm building a category template and I'm using something like:
>
> <?php
> if (in_category('CATEGORY-NAME')) {
> load_template(TEMPLATEPATH . '/category-special.php');
> }
> else {
> get_header();
> load_template(TEMPLATEPATH . '/category-default.php');
> }  ?>
>
>
> but I have to use a cat ID and it's necessary I use the category name.
>
> Any help would be appreciated, thanks.
> _______________________________________________
> wp-pro mailing list
> wp-pro at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-pro



More information about the wp-pro mailing list