Make WordPress Core


Ignore:
Timestamp:
02/26/2004 09:42:47 PM (23 years ago)
Author:
emc3
Message:

Added per-post custom metadata support.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/template-functions-post.php

    r945 r946  
    444444}
    445445
     446/*
     447 * Post-meta: Custom per-post fields.
     448 */
     449 
     450function get_post_custom() {
     451        global $id, $post_meta_cache;
     452
     453        return $post_meta_cache[$id];
     454}
     455
     456function get_post_custom_keys() {
     457        global $id, $post_meta_cache;
     458       
     459        if (!is_array($post_meta_cache[$id]))
     460                return;
     461        if ($keys = array_keys($post_meta_cache[$id]))
     462                return $keys;
     463}
     464
     465function get_post_custom_values($key='') {
     466        global $id, $post_meta_cache;
     467
     468        return $post_meta_cache[$id][$key];
     469}
     470
     471// this will probably change at some point...
     472function the_meta() {
     473        global $id, $post_meta_cache;
     474       
     475        if ($keys = get_post_custom_keys()) {
     476                echo "<ul>\n";
     477                foreach ($keys as $key) {
     478                        $value = implode($post_meta_cache[$id][$key],',');
     479                       
     480                        echo "<li>$key: $value</li>\n";
     481                }
     482                echo "</ul>\n";
     483        }
     484}
     485
    446486?>
Note: See TracChangeset for help on using the changeset viewer.