'Remove a wordpress add_filter function from plugin
I have a plugin that is creating a custom template via add_filter:
// Create a template view for the new CPT
add_filter('single_template', [$this, 'setTemplateAVATAR'] );
public function setTemplateAVATAR ($template) {
global $post;
if ( $post->post_type == 'AVATAR' ) {
return self::generateCustomTemplate('avatar.php');
}
return $template;
}
I need to disable this somehow via functions file so that that instead of using it's custom template is uses the template defined in my theme. How would I go about disabling this filter from running?
Solution 1:[1]
You would take the add_filter()
hook and use remove_filter()
and try the hook name and function name parameters the same. Let me know if you have any questions! :)
remove_filter('single_template', 'setTemplateAVATAR' );
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | JayDev95 |