All Posts Tagged: ‘pagenow’

WordPress Wednesdays: Get the Current Page

I was writing some functions that are used in the admin for my commercial WordPress theme: Lucidity and stumbled upon a great variable in WordPress: $pagenow. This variable will return the current page you are on and is great form admin functions – especially those that you want to only make available on certain pages.

To use this – just add it to your functions as a global variable, then you can use it to load in specific js/functions:
[php]
global $pagenow;
if (($pagenow == ‘admin.php’) && ($_GET['page'] == ‘sdac_appearance’)) {}
[/php]

This proved to be very helpful when dealing with some finicky JS.