There are cases where you need to change the features supported by a theme. For example, you may be creating a child theme with different capabilities, or you may need to disable a feature to remove conflicts. Either way, you can remove theme support with the following technique.
add_action( 'after_setup_theme', function() {
remove_theme_support( 'title-tag' );
}, 20 );
This example removes title-tag
support, but you can change to the feature of your choice. See Theme Features « WordPress Codex for a list of theme identifiers.
How it works
This snippet adds a handler for the after_setup_theme
hook. This hook is called on each page after the theme is initialized. Once the theme has been initialized, it calls remove_theme_support
to deregister support for title-tag
. This approach is commonly used by child themes to override the configuration of the parent theme.
How to use the snippet
If you need this code to fix a conflict on your website, then use a code plugin such as FluentSnippets. A code plugin lets you define small snippets of code without changing your theme or WordPress files. You should set this snippet to execute on all pages.
Reference
- add_action() – Function | Developer.WordPress.org
- after_setup_theme – Hook | Developer.WordPress.org
- remove_theme_support() – Function | Developer.WordPress.org
- Theme Features « WordPress Codex
See also
- How to fix duplicate title tags when using Raft and Yoast SEO – an example of using this technique to fix an obscure interaction between the Raft theme and the Yoast SEO plugin.
Leave a Reply