Home / admin / Show absolutely all custom fields for each post
  • How to Show absolutely all custom fields for each post

    displaying raw meta data in admin

    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.

    ( click code to copy )

    wordpress snippet : PHP

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

    ( WordPress codex functions, hooks, in this snippet. )

    get_post, get_post_meta, add_action, absint, _n, wp,
  • Jack

    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.

  • 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 ?