get_post_custom example

            $post_format = get_post_format( $post_id );
            if ( empty( $post_format ) ) {
                $post_format = 'standard';
            }

            $sticky = false;
            if ( is_sticky( $post_id ) ) {
                $sticky = true;
            }

            $enclosure = array();
            foreach ( (array) get_post_custom( $post_id ) as $key => $val ) {
                if ( 'enclosure' === $key ) {
                    foreach ( (array) $val as $enc ) {
                        $encdata             = explode( "\n", $enc );
                        $enclosure['url']    = trim( htmlspecialchars( $encdata[0] ) );
                        $enclosure['length'] = (int) trim( $encdata[1] );
                        $enclosure['type']   = trim( $encdata[2] );
                        break 2;
                    }
                }
            }

            

function rss_enclosure() {
    if ( post_password_required() ) {
        return;
    }

    foreach ( (array) get_post_custom() as $key => $val ) {
        if ( 'enclosure' === $key ) {
            foreach ( (array) $val as $enc ) {
                $enclosure = explode( "\n", $enc );

                // Only get the first element, e.g. 'audio/mpeg' from 'audio/mpeg mpga mp2 mp3'.                 $t    = preg_split( '/[ \t]/', trim( $enclosure[2] ) );
                $type = $t[0];

                /** * Filters the RSS enclosure HTML link tag for the current post. * * @since 2.2.0 * * @param string $html_link_tag The HTML link tag with a URI and other attributes. */

/** * Retrieves post custom meta data field. * * @since 1.5.0 * * @param string $key Meta data key name. * @return array|string|false Array of values, or single value if only one element exists. * False if the key does not exist. */
function post_custom( $key = '' ) {
    $custom = get_post_custom();

    if ( ! isset( $custom[ $key ] ) ) {
        return false;
    } elseif ( 1 === count( $custom[ $key ] ) ) {
        return $custom[ $key ][0];
    } else {
        return $custom[ $key ];
    }
}

/** * Displays a list of post custom fields. * * @since 1.2.0 * * @deprecated 6.0.2 Use get_post_meta() to retrieve post meta and render manually. */
/** * Retrieves meta field names for a post. * * If there are no meta fields, then nothing (null) will be returned. * * @since 1.2.0 * * @param int $post_id Optional. Post ID. Default is the ID of the global `$post`. * @return array|void Array of the keys, if retrieved. */
function get_post_custom_keys( $post_id = 0 ) {
    $custom = get_post_custom( $post_id );

    if ( ! is_array( $custom ) ) {
        return;
    }

    $keys = array_keys( $custom );
    if ( $keys ) {
        return $keys;
    }
}

Home | Imprint | This part of the site doesn't use cookies.