Created
April 3, 2015 17:03
-
-
Save will83/3ebc304627568984fff1 to your computer and use it in GitHub Desktop.
Function to get all custom fields within the $post global
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
<?php | |
function get_all_post_custom_fields( $posts ) { | |
for ( $i = 0; $i < count($posts); $i++ ) { | |
$custom_fields = get_post_custom( $posts[$i]->ID ); | |
$posts[$i]->custom_fields = $custom_fields; | |
} | |
return $posts; | |
} | |
add_filter( 'the_posts', 'get_all_post_custom_fields' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment