Last active
June 29, 2016 20:16
-
-
Save rbk/09051c720e2d3fccd0e04b2a9a482065 to your computer and use it in GitHub Desktop.
WordPress - Get all post metadata as a nice object that is easier to work with
This file contains hidden or 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_post_meta_object( $id ) { | |
| $object = new stdClass(); | |
| $meta = get_post_meta( $id ); | |
| foreach( $meta as $key => $value ) { | |
| $object->{$key} = $value[0]; | |
| } | |
| return $object; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment