Add content before/after admin post wp-list-table

This has probably been solved many times here on this site, but maybe not with all your requirements? So let me try to answer it here:

You can try to use the all_admin_notices and in_admin_footer actions, wrapped inside the load-edit.php action to target the edit.php page:

add_action( 'load-edit.php', function(){

   $screen = get_current_screen(); 

    // Only edit post screen:
   if( 'edit-post' === $screen->id )
   {
        // Before:
        add_action( 'all_admin_notices', function(){
            echo '<p>Greetings from <strong>all_admin_notices</strong>!</p>';
        });

        // After:
        add_action( 'in_admin_footer', function(){
            echo '<p>Goodbye from <strong>in_admin_footer</strong>!</p>';
        });
    }
});

This will render like the following screenshots:

Before:

Before

After:

After

You can then easily modify this to target the edit.php screen for different custom post types.

Hope this helps.

Leave a Comment