ifacethoughts

post_meta_cache

post_meta_cache is one more global variable used for caching as WordPress. It is a multi-dimensional array which stores the custom fields for a post. The custom fields are stored by the post ID and then by the custom field key. Multiple instances of custom fields are allowed.

Plugin and theme developers need not access post_meta_cache directly, it is used by WordPress internally in the following internal and template functions.

Internal Functions

  • add_post_meta($post_id, $key, $value, $unique = false): adds custom field with specified key and value to the specified post. If unique is true, another custom field with duplicate key is not added. This can be used by developers who are developing plugins for the the admin area, especially for adding more information to the post structure.
  • delete_post_meta($post_id, $key, $value): deletes the custom field with specified key and value from the specified post.
  • get_post_meta($post_id, $key, $single = false): returns custom field value for specified key for the specified post.
  • update_post_meta($post_id, $key, $value, $prev_value = ''): updates the custom field value for specified key in the specified post.

Template Functions

  • get_post_custom($post_id = 0): returns all the custom fields for specified post as an array. If post ID is not specified, current post is considered.
  • get_post_custom_keys(): returns keys of all the custom fields for specified post as an array
  • get_post_custom_values($key = ''): returns all values of the specified custom fields key for specified post as an array
  • post_custom($key = ''): returns all the custom fields with specified key for the current post.
  • the_meta(): displays all the custom fields of the current post as a unordered list.

Back to full list of global variables.

Technorati tags: , ,

Discussion [Participate or Link]

  1. references» Blog Archive » Wordpress Global Variables said:

    […] $post_meta_cache […]

Say your thought!

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
My bookmarks

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.