4

I know there are two hooks to add content before and after a taxonomy wp-list-table.

Is there an action to add content after the post type wp-list-table on the edit.php page?


For $taxonomy List Tables:

add_action( 'category' . '_pre_add_form', 'copy_above_form' );
function copy_above_form( $taxonomy ) {
    echo '<p>Above the WP-List-Table</p>';
}

add_action( 'after-' . 'category' . '-table', 'copy_below_table' );
function copy_below_table( $taxonomy ) {
    echo '<p>Below the WP-List-Table</p>';
}

Reference: https://trepmal.com/action_hook/after-category-table/

Thanks!

1 Answer 1

4

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.

2
  • Thanks birgire, I did notice this was an option - but it was adding onto the admin footer. The other alternative was via a javascript function, but I did not think that was the correct way to do it. Since there are no actions to hook onto the edit-post page, I believe this may only be the accepted answer. Thanks!
    – Roc
    Apr 5, 2014 at 16:32
  • I did check the WP_List_Table class and the WP_Posts_List_Table class, but I didn't find any useful hooks there. It would be handy if one could extend these classes and replace the current instances ;-) The instance is created via $wp_list_table = _get_list_table('WP_Posts_List_Table'); but there's no filter/hook in this internal function _get_list_table() see here. The Codex also says: This is a private, internal WordPress function. It should not be called directly or used by developers.
    – birgire
    Apr 5, 2014 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.