X

How to Show Absolutely All Custom Fields For Each Post

Snippets by IsItWP

Are you looking for a way to display all columns for each post? While there’s probably a plugin for this, we have created a quick code snippet that you can use to show absolutely all custom fields for each post.

Instructions:

All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:

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
    }
}

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 11 best WordPress quiz plugins and how to add a portfolio to your WordPress blog.

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!
[60% OFF Today!]
[60% OFF Today!]
[10% OFF Today!]
[10% OFF Today!]
[50% OFF Today!]
[50% OFF Today!]