Replace function on plugin that works with WooCommerce
-
Hello
I need help in replacing a function that is not pluggable from a plugin that I use with WooCommerce in my child theme.
I have been researching and I would like if you can confirm that this is the steps I should take.
This is the example function on the parent theme on file functions.php:
<?php function parent_function() { // Contents for your function here. } add_action( 'init', 'parent_function' ); ?>To remove it on my child theme in file functions.php i should code:
<?php function child_remove_parent_function() { remove_action( 'init', 'parent_function' ); } add_action( 'wp_loaded', 'child_remove_parent_function' ); ?>Is it correct so far?
Now I would like to add my custom function to replace that one.
I am not sure how to do this. Is this the code I should write on functions.php file of my child theme?<?php function my_custom_function() { // Contents for your custom function here. } add_action( 'init', 'my_custom_function' ); ?>So, by the end my functions.php file on child theme should go like this?
<?php function child_remove_parent_function() { remove_action( 'init', 'parent_function' ); } add_action( 'wp_loaded', 'child_remove_parent_function' ); ?> <?php function child_remove_parent_function() { remove_action( 'init', 'parent_function' ); } add_action( 'wp_loaded', 'child_remove_parent_function' ); ?> <?php function my_custom_function() { // Contents for your custom function here. } add_action( 'init', 'my_custom_function' ); ?>Whith this code will my custom function replace the parent function, preventing the parent function from being fire?
Thank you very much
The topic ‘Replace function on plugin that works with WooCommerce’ is closed to new replies.