Home > Blockchain >  Overwrite plugin function in child theme wordpress
Overwrite plugin function in child theme wordpress

Time:01-23

Maybe this has been asked somewhere, but let me try to explain:

In a plugin of my wordpress website, I have a function that I want to overwite, but it won't let me.

Here is how it looks like:

function this_is_funtionA() {

    $content = this_is_functionB('somevalue1', 'somevalue2');  // this function I am trying to overwrite

    return $content;

}
add_filter('the_content', 'this_is_funtionA', 5);


function this_is_funcionB($item1, $item2) {

    // some code

}

How can I overwrite this_is_functionB?

CodePudding user response:

you could try this :

remove_filter('the_content', 'this_is_funtionA', 5);
add_filter('the_content', 'my_custom_functionA', 5);

function my_custom_functionA() {
    $content = my_custom_functionB('somevalue1', 'somevalue2');
    return $content;
}

function my_custom_functionB($item1, $item2) {
    // your custom code
}
  • Related