ifacethoughts

category_cache

Wordpress uses category_cache global variable to cache categories by posts. This means that it can be queried for categories by providing the post ID. It is a two-dimensional array set in the function update_post_category_cache($post_ids) defined in [wordpress root folder]/wp-includes/functions.php.

The cache can improve performance by saving repeated trips to the database for querying the same data.

Wordpress uses category_cache internally in the following functions:

  • get_the_category($post_id = false): returns categories the specified post is classified under. An array of the categories is returned.
  • in_category($category): tells whether the current post is in the specified category or not.

Back to full list of global variables.

Technorati tags:

Discussion [Participate or Link]

  1. Abhijit Nadgouda @ iface knwsfb7v3y » Blog Archive » post_cache said:

    [...] category_cache [...]

  2. Abhijit Nadgouda @ iface » Blog Archive » Wordpress Global Variables said:

    [...] $category_cache [...]

Say your thought!

Who are you?

If you want to use HTML you can use these tags: <a>, <em>, <strong>, <abbr>, <code>, <blockquote>. Closing the tags will be appreciated as this site uses valid XHTML.

freshthoughts

contactme

Abhijit Nadgouda
iface Consulting
India
+91 9819820312
Y!: anadgouda
GTalk: anadgouda@gmail.com
MSN: anadgouda@hotmail.com
Skype: anadgouda
My bookmarks

currentproject

Complete Wellbeing

badgesand...

This is the weblog of Abhijit Nadgouda where he writes down his thoughts on software development and related topics. You are invited to subscribe to the feed to stay updated or check out more subscription options. Or you can choose to browse by one of the topics.

Twitter - Using Envy Code R and liking it. Thank you Damien. http://tinyurl.com/688mft