My theme doesn't use the tag line, how can I remove it from the customizer?
6 Answers
Late to the party but this will do the trick:
$wp_customize->remove_control('blogdescription');
You want to remove just that control, not entire section as suggested above.
-
1The setting should also be removed: $wp_customize->remove_setting('blogdescription')– mimarcelCommented Nov 12, 2018 at 20:57
-
Will this also remove any stored value that's currently in there? I'm having an issue where I want to delete existing setting/controls that have existing data, but the data is still being called back. wordpress.stackexchange.com/questions/329343/…– LeeCommented Feb 20, 2019 at 11:35
Remove a pre exising customizer setting in wordpress theme with this code.
add_action( "customize_register", "ruth_sherman_theme_customize_register" );
function ruth_sherman_theme_customize_register( $wp_customize ) {
//=============================================================
// Remove header image and widgets option from theme customizer
//=============================================================
$wp_customize->remove_control("header_image");
$wp_customize->remove_panel("widgets");
//=============================================================
// Remove Colors, Background image, and Static front page
// option from theme customizer
//=============================================================
$wp_customize->remove_section("colors");
$wp_customize->remove_section("background_image");
$wp_customize->remove_section("static_front_page");
}
I found out the WP_Customize_Manager class has a function called remove_section()
. In your function hooked to customize_register
you can just do:
$wp_customize->remove_section('nav');
$wp_customize->remove_section('static_front_page');
You can find the ID of the section (i.e. 'nav') if you inspect the accordion title bar of the section. Look at the ID of the containing <li>
tag and it's the portion of the string after "customize-section-"
. I.E.:
<li id="customize-section-static_front_page" class="control-section customize-section">
-- the ID is "static_front_page"
-
That looks better than my solution so I will give you the tick - I haven't tested it but I suppose you have ... I don't get the title_tagline though - surely it should say static_front_page, is that a typo BAC? Commented Aug 24, 2012 at 1:29
-
@byronyasgur yep, that was a copy pasta error, fixed now. Thanks!– jessicaCommented Aug 24, 2012 at 1:32
-
Actually, this isn't the correct answer. This removes the entire section that contains both the site title & tagline. The question is asking for only the tagline. Look at the answer below by @byronyasgur– BFTrickCommented Nov 15, 2012 at 1:13
Accoring to OTTO
One final thing you can add to a section is a “theme_supports” option. This will make the menu not appear unless the theme supports something. If you’re putting this code in a theme itself, then you already know what the theme supports, so it doesn’t make much sense. The core uses this to not show the header and background options if the theme doesn’t support them.
So I put that together with
$wp_customize->get_setting('blogdescription')->transport='postMessage';
... and discovered that the following code worked. I put false
in for the theme_supports ... not sure what I really should be putting in ... maybe someone a bit more expert can improve on this.
$wp_customize->add_control('blogdescription')->theme_supports=false;
if the section / panel or control core , it is always better to disable them in place of removing.
add_action( 'customize_register', 'wp_stackexchange_58932' );
function wp_stackexchange_58932($wp_customize){
$wp_customize->get_section( 'static_front_page' )->active_callback = '__return_false';
$wp_customize->get_section( 'custom_css' )->active_callback = '__return_false';
}
-
1Great tip, i used it to always show the static_front_page setting, even if there is no page (by default it only shows when there is a page existing on the site)– LarzanCommented Oct 4, 2019 at 10:38
If you are using this in a plugin you should use priority argument like 999 and it will work in the plugin.
add_action( "customize_register","wpcb_theme_customize_register",999,1);
function wpcb_theme_customize_register($wp_customize){
$wp_customize->get_setting('blogdescription')->transport='postMessage';
}
-
+1 for priority > 10. In my case I change customizer by a child theme. Without setting priority $wp_customize->get_setting() will return null since this function seems to be called before parent theme creates the setting.– FilCommented Feb 6, 2020 at 21:35