コード例 #1
0
ファイル: functions.php プロジェクト: dangeles/Phinch
function pf_meta_by_name($name)
{
    foreach (pf_meta_structure() as $meta) {
        if ($name == $meta['name']) {
            return $meta;
        }
    }
}
コード例 #2
0
/**
 * Retrieve post_meta data in a way that insures the correct value is pulled.
 *
 * Function allows users to retrieve the post_meta in a safe way standerdizing against
 * the list of accepted PressForward meta_slugs. It deals with depreciated post_meta.
 *
 * @since 3.x
 *
 * @param int $id Post ID.
 * @param string $field The post_meta field to retrieve.
 * @param bool $obj If the user wants to return a PressForward post_meta description object. Default false.
 * @param bool $single If the user wants to use the WordPress post_meta Single decleration. Default true.
 *
 * @return string|array Returns the result of retrieving the post_meta or the self-descriptive meta-object with value.
 */
function pf_retrieve_meta($id, $field, $obj = false, $single = true)
{
    $field = pf_pass_meta($field, $id);
    $meta = get_post_meta($id, $field, $single);
    if ($obj) {
        $metas = pf_meta_structure();
        $meta_obj = $metas[$field];
        $meta_obj['value'] = $meta;
        return $meta_obj;
    }
    return $meta;
}