WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wrote a WordPress plugin that creates an admin page for deciding what posts go in a feature slider on the front page. Everything works fine and I'm simply calling to the function inside the plugin with

    <?php uwffs_display(); ?> 

in the home.php file.

The issue is that if I were to deactivate the plugin, the home page breaks at the point the

    <?php uwffs_display(); ?> 

function call occurs and stops rendering the rest of the page.

What is a more graceful way I can call this plugin's function so that, if deactivated, it will load the rest of the page?

One thought is I could write it as:

    <?php if(function_exists('uwffs_display'))

Is that the best way?

share|improve this question

migrated from stackoverflow.com Aug 16 '11 at 17:33

This question came from our site for professional and enthusiast programmers.

up vote 4 down vote accepted

The other option would be to use any hooks available in the Theme, which would allow your Plugin to inject the slider at a filter or action hook. If the Plugin is deactivated, its add_action() or add_filter() call is never run, nothing attempts to be added to the template, and, voila: no breakage.

But, barring that (and since Themes that offer such custom hooks are still in the minority), function_exists() wrapper is the way to go. So +1 to @rmlumley.

share|improve this answer

Yes it is. Checking for the existence of the function in the way that you just posted is the proper way of doing this.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.