Simple WordPress function for live site changes

Often a client wants us to change things on a live site, and whilst sometimes those changes are fairly minor, there are times where you’re making fairly substantial changes to a part of the site. I’m not talking about such huge changes that justify running a theme switcher or making a local copy of the site, but, well you get the idea.

Anyway, add this simple function to your functions.php file and then all you need to do is add ?devel to the URL to see changes.

* Page testing function, returns true if ?devel in URL
* @return     BOOL        Returns true if ?devel in URL
function pa_devel() {
	if (isset($_GET['devel'])) {
		return TRUE;
	} else {
		return FALSE;

You can use this in your code by doing something like:

<?php if (pa_devel()){ ?>

// do stuff for development

<?php } else { ?>

// show the normal live site code

<?php } ?>


  • transmitstudio

    This looks handy, but I have a question: I get where to put this code, but how does the WP engine know what should be live and what should be shown only to the developer?

    • Hi transmitstudio,

      So once you’ve put the function in your functions.php and you’ve done an if (pa_devel()){} in your template somewhere, you can just add the parameter ‘devel’ to your URL.

      So if your page is, then you can see the development code by going to

      Obviously if you feel worried that someone might guess to add the ?devel parameter you could easily change the function to look for a random long string.

      I used to do things like if (is_user_logged_in()).. but I so often found that the client wasn’t already logged in and so wouldn’t see the changes. This method means I know that they’ll see it.

      Hope that helps!