What I am trying to accomplish is placing custom widget on an admin page (edit.php). I tried using these two functions:
Places custom html right below < body > (above all page content)
add_action( 'load-edit.php', 'your_function' );
function your_function() {
include( plugin_dir_path( __FILE__ ) . 'quickpost/quickpost.php');
}
Places custom html below the < footer >
add_action('admin_footer', 'post_add_quickpost');
function post_add_quickpost() {
include( plugin_dir_path( __FILE__ ) . 'quickpost/quickpost.php');
}
Here is were I am trying to place the widget, just above the posts table on the edit.php page. http://i.imgur.com/QKHkEqs.jpg
Is there a way I can specify where to place the code? I would prefer to work with the ‘load-edit.php’ action, but if that is not possible – it is okay with me. Thanks!
As far as I know you have 2 options.
Using
admin_footer
orload-edit.php
and position withabsolute
orfixed
, or use JavaScript.If you creating a completely new posts screen (not a default posts, pages, etc), you can extend
WP_List_Table
class, specifically theextra_tablenav
function.For example:
As far as I can tell, extending this class can only work on a custom admin page, and not the current existing ones, as there are no hooks available. You can read more about it here: http://codex.wordpress.org/Class_Reference/WP_List_Table
I think that
add_action( 'load-edit.php', 'your_function' );
is the correct way to do it, since it’s the only admin action designed to be fired only on a specific page. I would just style my metabox so that it’s absolutely positioned at the bottom of the posts list.You could also look at some other available actions available during an admin page load. If you find one that’s more appropriate, you could use a basic page check to load your plugin on only the desired page, something like: