X

Show absolutely all custom fields for each post

This snippet will display absolutely all custom fields for each post. Even custom fields you may not even be aware exist like _edit_lock and others. We have Justin Sternberg to thank for writing this snippet that was submitted a while ago as part of his tutorial on wordpress custom fields. Since this snippet is not available other than in the tutorial I figure it should be posted separately.


add_action( 'all_admin_notices', 'wpsnipp_show_all_custom_fields' );
function wpsnipp_show_all_custom_fields() {
    if ( isset( $_GET['post'] ) ) {
        $post_id = absint( $_GET['post'] );
        ?>
        <div id="message" class="updated">
            <h3>All post meta:</h3>
            <xmp><?php print_r( get_post_meta( $post_id ) ); ?></xmp>
        </div>
        <?php
    }
}

Comments  Leave a Reply

  1. S?awek Grochowski May 4, 2015 at 6:09 pm

    Thank you for your article & code. Finally I see all custom fields but I would like to modify them in easy way. Is there any chance to just display all custom fields like it is “Edit Post” -> “Custom Fields” screen where I can create new, delete & update ?

  2. How could I use this code to display all custom meta from all posts of a certain post type? I need to populate a table, so each column needs to be populated with the values of one custom field/name. I can do that with php, but I don’t know how to retrieve all the keys/values.

    1. Hi Jack,
      This snippet is used for the admin area of the website so that you can see meta data and ensure everything is working correctly. However the author of this snippet Justin, also has a 5 part tutorial on post meta that you should find useful.

      http://wpsnipp.com/index.php/tutorial/post-meta-intro-wordpress-custom-fields/

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!