The action load-edit.php
is not needed. The answer on Stack Overflow is based on this WPSE answer: How do you create a custom edit.php / edit pages page that uses pre_get_posts
, that’s why it was encapsulated inside load-PAGE
action.
On the screen edit.php
we don’t have any action hooks to insert content. We can only use the filter views_edit-POST_TYPE
to do something there. With jQuery we can adjust the position on screen.
add_filter( 'views_edit-POST_TYPE', function($views){
echo '<h2 style="display:none;" id="my-element">My Custom HTML</h2>';
echo "<script>
jQuery(document).ready(function($){
$('#my-element').detach().insertBefore('#ajax-response').fadeIn();
});
</script>";
return $views;
});
Without jQuery it prints on position 1, and on position 2 using it.