Could anyone be kind enough to descrive how to I can detect (in my functions file) when admin an user is on the 'All Posts' page?
I have tried get_post_type() but it returns nothing.
Thanks.
If you need exactly on All Posts
page, Not on All Pages
, nor All Products
or etc -
if
(
'edit.php' === $GLOBALS['pagenow']
&& (
isset( $GLOBALS['typenow'] )
&& '' == $GLOBALS['typenow']
|| 'post' == $GLOBALS['typenow']
)
)
{
// Do what you like...
}
If I understood you correctly, this is what you are looking for:
if (
'edit.php' === $GLOBALS['pagenow']
&& ! isset($_GET['action'])
) {
// Do what you like...
}
Take a look at get_current_screen():
function do_something_on_all_posts_page() {
$screen = get_current_screen();
if ( $screen['base'] == 'edit' && $screen['post_type'] == 'post' ) {
/* Your code here */
}
}
add_action( 'current_screen', 'do_something_on_all_posts_page' );
All posts
page ? A normal WordPress Page create through WP Admin -> Pages ?