Title: How to replace a function within a plugin?
Last modified: August 20, 2016

---

# How to replace a function within a plugin?

 *  [BunnyBomb](https://wordpress.org/support/users/bunnybomb/)
 * (@bunnybomb)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/how-to-replace-a-function-within-a-plugin/)
 * Hello,
 * I would like to know if it’s possible to override a function declared within 
   a plugin, by inserting code into my child theme’s functions.php file.
 * Based on my Google research, I’ve found I can either:
    1. Edit the plugin files
   and risk changes being overwritten later 2. Copy the entire plugin into my functions
   php, and miss out on future updates from the plugin author
 * Is there another way to do this?
 * I’ve tried placing my edited function into my child theme’s functions.php file,
   surrounding it by this (example only):
 *     ```
       if( !function_exists('the_plugin_function_name;)) {
            function my_better_function( 'code goes here' );
       }
       ```
   
 * I’d appreciate some advice here. I’m only a beginner with php.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [BunnyBomb](https://wordpress.org/support/users/bunnybomb/)
 * (@bunnybomb)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/how-to-replace-a-function-within-a-plugin/#post-2581791)
 * Since I know folks prefer specifics…
 * Here is the modified function I would like to use, to replace the one contained
   in the plugin files. [http://pastebin.com/RXmR4H3J](http://pastebin.com/RXmR4H3J)
 * I needed to make some cosmetic changes from line 85 to 97, then a few more from
   line 139 to 156. As you can see from the code I’ve posted, I’ve attempted to 
   surrounded it with function_exists(), however it doesn’t work when I paste into
   my child theme’s functions.php file.
 * Would appreciate some advice here.
 *  Thread Starter [BunnyBomb](https://wordpress.org/support/users/bunnybomb/)
 * (@bunnybomb)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/how-to-replace-a-function-within-a-plugin/#post-2581953)
 * So nobody knows a way to override a plugin function without editing it directly?
 * I guess it can’t be done then.
 *  [postoy](https://wordpress.org/support/users/postoy/)
 * (@postoy)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/how-to-replace-a-function-within-a-plugin/#post-2582176)
 * I presume you are trying to replace a plugin’s function within a class. It’s 
   called monkey patching and your limitations are with PHP itself. More here:
 * [http://stackoverflow.com/questions/137006/php-redefine-class-methods-or-class](http://stackoverflow.com/questions/137006/php-redefine-class-methods-or-class)
 *  [postoy](https://wordpress.org/support/users/postoy/)
 * (@postoy)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/how-to-replace-a-function-within-a-plugin/#post-2582177)
 * Apologies for the dated information. You should be able to achieve this with 
   PHP 5.3+

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘How to replace a function within a plugin?’ is closed to new replies.

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)

 * 4 replies
 * 2 participants
 * Last reply from: [postoy](https://wordpress.org/support/users/postoy/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/how-to-replace-a-function-within-a-plugin/#post-2582177)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
