Created
February 7, 2014 03:56
-
-
Save cassler/8857177 to your computer and use it in GitHub Desktop.
wp-get-meta-keys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get all meta keys for given object. | |
* | |
* Finds all custom meta keys for a given post and extracts them to an array for easy access. | |
* @example $meta = den_get_meta; | |
* @example echo ($meta['my-key'] ? $meta['my-key'] : null ); | |
* @return array of meta keys for post | |
* @author Darin Cassler | |
* @package den_framework | |
* @subpackage den_custom_hooks | |
**/ | |
function den_get_meta() { | |
global $post; | |
$meta = array(); | |
$custom_field_keys = get_post_custom_keys($post->ID); | |
foreach ( $custom_field_keys as $key => $value ) { | |
$valuet = trim($value); | |
if ( '_' == $valuet{0} ) | |
continue; | |
$meta_values = get_post_meta($post->ID,$value); | |
$meta[$value] = join(', ',$meta_values); | |
} | |
return $meta; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment