How to remove parent themes function file filter in child themes function file

How to remove parent themes function file filter in child themes function file.

function file

Read More
function add_opengraph_doctype( $output ) {                                            

    return $output. ' prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#"';
}
add_filter('language_attributes', 'add_opengraph_doctype');

And I have try to remove child theme like as

remove_filter('language_attributes', 'add_opengraph_doctype');

but it’s not working.

Related posts

2 comments

  1. A child theme’s functions.php file will run before the parent, so it will not be registered yet.

    You could wait for the init action to remove the filter.

    function remove_language_attributes() {                                            
        remove_filter('language_attributes', 'add_opengraph_doctype');
    }
    add_filter('init', 'remove_language_attributes');
    
  2. You can set priority in your filter like this :

     add_filter('language_attributes', 'add_opengraph_doctype', 10);
    

    and set child them filter priority to grater than 10.

Comments are closed.