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.

Related Posts

One Response to “WordPress Wednesdays: Get the Current Page”

  1. Jeff says:

    Thanks for sharing this function. I was working on a plugin the other day and this will come in handy when I get back to it!

    Reading back through your site now to see what other info I’ve missed.

Leave a Reply