[wp-hackers] Obtaining category id from new permalinks system

Denis de Bernardy denis at semiologic.com
Tue Jan 3 16:53:35 GMT 2006


This thingy was discussed a little earlier in the list. Could be what you're
looking for:

$GLOBALS['wp_object_cache']->cache['category'][$cat]

D.

> -----Original Message-----
> From: wp-hackers-bounces at lists.automattic.com 
> [mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of 
> Aaron Brazell
> Sent: Tuesday, January 03, 2006 5:46 PM
> To: wp-hackers at lists.automattic.com
> Subject: Re: [wp-hackers] Obtaining category id from new 
> permalinks system
> 
> 
> On 1/3/06, Rob Schumann <robs_wph at rs-tc.com> wrote:
> 
> 	Hi,
> 	
> 	I need to be able to obtain the id of the requested category
> 	when permalinks are enabled.
> 	
> 	The method used under WP1.5.* no longer works and I cannot
> 	find any hint as to where to look for the information under 
> 	2.0.
> 	
> 	So, any pointers as to where this, and other information
> 	transmitted via permalinks would be very gratefully
> 	received...
> 
> 
> Untested, but you could add something like this to a plugin.. 
> 
> 
> function get_category_by_name($catname)
>   {
>   global $wpdb;
>   return $wpdb->get_var("SELECT cat_ID FROM 
> ".$wpdb->categories." WHERE category_nicename = 
> ''.sanitize_title($catname).");
>   }
> 
> If you want more than just the ID, you can do that by 
> changing the query.
> 
> That what you're looking for?
> 
> 




More information about the wp-hackers mailing list