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

Aaron Brazell aaron at technosailor.com
Tue Jan 3 16:45:53 GMT 2006


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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://comox.textdrive.com/pipermail/wp-hackers/attachments/20060103/5a8e0a91/attachment-0001.htm


More information about the wp-hackers mailing list