34 votes
Accepted

Link to specific Customizer section

As you've already discovered, links to the customizer always start with /wp-admin/customize.php. Append ?autofocus[section] =section_name to checkout your section within the customizer. Both ...
Sven's user avatar
  • 3,624
14 votes
Accepted

Custom Image section in Customizer

So I did some research on the matter and I found a solution. Basically WordPress has this cool feature where you can call something called get_theme_mod so what I essentially did was add get_theme_mod ...
Stephen's user avatar
  • 1,294
12 votes
Accepted

How do I implement selective refresh with a customizer setting?

Create a function to output the selectively refreshed template code (I wrapped the HTML within <div class="cta-wrap"> to make it easier to target this particular block of markup.) function ...
Dave Romsey's user avatar
  • 17.7k
12 votes
Accepted

Is there any way to add placeholder for WordPress Customizer text input fields

You can use the input_attrs argument to pass attributes to the input: $wp_customize->add_control('directorist_address', array( 'label' => __('Address', 'directorist'), 'section' ...
Jacob Peattie's user avatar
11 votes
Accepted

add_action customize_register not working

You always need to be sure that three things are defined (section, setting and control). If you are adding a control to an already defined section, i.e. title_tagline, then you don't need to re-...
Capiedge's user avatar
  • 778
10 votes
Accepted

Hide Theme options and Customize Admin menu

Direct answer: add_action( 'admin_menu', function() { global $current_user; $current_user = wp_get_current_user(); $user_name = $current_user->user_login; //check condition ...
coolpasta's user avatar
  • 919
9 votes
Accepted

How to remove menus section from WordPress theme customizer

Try nav_menus instead of menus with remove_panel() function mytheme_customize_register( $wp_customize ) { //All our sections, settings, and controls will be added here $wp_customize->...
AddWeb Solution Pvt Ltd's user avatar
8 votes
Accepted

Editing the custom background CSS

Yes, that is possible. Take a look at the codex and you will see that you can pass arguments with add_theme_support( 'custom-background'). One of them is the callback function that generates the <...
cjbj's user avatar
  • 14.2k
8 votes
Accepted

Add button to Customizer

There are three things you need to do in particular. As there are no settings associated with the control, you need to explicitly supply an empty array for settings, as otherwise it will try to look ...
Weston Ruter's user avatar
  • 4,020
8 votes
Accepted

possible to make sections in theme customizer sortable and saveable at publish button clicked?

Simple tutorial - How to sort customizer sections in the panel and add order to theme. 1. You must use prefixes to do this because customizer don't support custom classes. ctmss_panel_ - for panels ...
Michael's user avatar
  • 172
7 votes

Appearance->Editor not visible

I had a similar problem (albeit 3 years later) and after some research I had a process for potentially identifying the source of the problem and subsequently found that my issue was hidden in a plugin ...
WPDavid's user avatar
  • 199
7 votes
Accepted

Add a dropdown to theme customizer

Add Section to Theme Customizer: $wp_customize->add_section( 'parsmizban_options', array( 'title' => __( 'Theme Options', 'parsmizban' ), //Visible title of section 'priority' ...
Farhad Sakhaei's user avatar
7 votes
Accepted

Customizer - instantiating settings and controls via javascript

If you register your settings on the server then you do not need to register them on the client in JS, as this will be done for you. Here are some examples creating controls after you have created the ...
Weston Ruter's user avatar
  • 4,020
6 votes

Repeater field in Customizer

You could use or take a reference from Kirki. It is a framework that allow to add customizer controls with less code. Take a look to Kirki::Repeater_Control here.
koMah's user avatar
  • 209
6 votes

Customizer sanitize_callback for input type number

Add a setting, specifying the sanitize_callback: $wp_customize->add_setting( 'my_input', array( 'default' => '100.00', 'sanitize_callback' => 'sanitize_float', ) )...
mistertaylor's user avatar
6 votes
Accepted

How to mix partial and full page refresh in the same section of the customizer?

tl;dr See standalone example plugin that demonstrates initiating a full refresh when a selective refresh request enqueues different scripts or styles and also which re-initializes JS behaviors for ...
Weston Ruter's user avatar
  • 4,020
6 votes

How to remove menus section from WordPress theme customizer

The correct way to disable nav menus in the customizer is via the customize_loaded_components filter as documented on its hook reference page: /** * Removes the core 'Menus' panel from the ...
Weston Ruter's user avatar
  • 4,020
6 votes
Accepted

WordPress Customizer: How can you have multiple active callbacks on one control?

You can create a third active callback function that just references the two existing ones, for example via an anonymous function (PHP≥5.3): // About Block Button Text $wp_customize->add_setting( '...
Weston Ruter's user avatar
  • 4,020
6 votes
Accepted

Where to get the unsaved list of widgets in customizer?

You can get the list of widgets in a sidebar via: wp.customize('sidebars_widgets[sidebar-1]').get() This is a list of the widgets' IDs. The sidebars_widgets[sidebar-1] is the setting ID for the ...
Weston Ruter's user avatar
  • 4,020
6 votes

Hide Theme options and Customize Admin menu

This would work in WordPress 5 add_action( 'admin_menu', function() { remove_submenu_page( 'themes.php', 'customize.php?return=' . urlencode($_SERVER['SCRIPT_NAME'])); });
FooBar's user avatar
  • 444
6 votes
Accepted

How to print the value of a custom control in the Customizer?

Your code is perfect just need to change 'theme_mod' instead of 'option' it will solve this. function themename_customize_register($wp_customize){ $wp_customize->add_setting( 'test_setting'...
Tejas Gajjar's user avatar
6 votes
Accepted

How do I remove a customiser option from a parent theme in a child theme?

From the documentation: To add, remove, or modify any Customizer object, and to access the Customizer Manager, use the customize_register hook: function themeslug_customize_register( $...
Sally CJ's user avatar
  • 38.9k
6 votes
Accepted

What is the difference between sanitize_text_field() and wp_filter_nohtml_kses()?

What Do They Do? wp_filter_nohtml_kses strips all HTML from a string, that's it. It does it via the wp_kses function and it expects slashed data, here's its implementation: function ...
Tom J Nowell's user avatar
  • 58.9k
6 votes
Accepted

Add settings to menu items in the Customizer

You're running up against an incomplete implementation of modifying nav menus in the Customizer. In particular, inside of the phpdoc for WP_Customize_Nav_Menu_Item_Setting::preview() you can see this ...
Weston Ruter's user avatar
  • 4,020
5 votes
Accepted

Theme Customizer : how to create multiple-level panel

For anyone that comes here looking for this, I was able to do it after battling with it for a few hours. The code is a bit extensive so did not want to post here, (mods feel free to let me now if ...
OriginalEXE's user avatar
5 votes

Get attachment id from WP Customizer

This is very old, but for someone coming here via search WP_Customize_Media_Control control in WP since 4.2 give you the attachment id. Ref: https://make.wordpress.org/core/2015/07/16/new-customizer-...
Satish Gandham's user avatar
5 votes

How to move Menus customizer section directly under Site Identity?

Update: I was curious and just searched this site for get_panel method and that seems to be the way to get and modify the panel instance. E.g. this question "How to access the nav_menus panel with the ...
birgire's user avatar
  • 66.9k
5 votes
Accepted

Set Default Page On Customizer Live Preview

The default URL being previewed is home_url( '/' ). When no url query parameter is present when opening customize.php, this is the preview URL that is used. You can override the previewed URL when ...
Weston Ruter's user avatar
  • 4,020
5 votes
Accepted

How to open the 404 page in the Theme Customizer preview?

Cool use case. Without any code, in order to load the 404 template, all you have to do is navigate to a non-existent URL on your site. Then, while being logged-in, click the Customize link in the ...
Weston Ruter's user avatar
  • 4,020
5 votes
Accepted

site identity section name?

The “Site Identity” section has the ID of title_tagline for historical reasons. If you want to see the IDs for the core sections, all you have to do is look at the source for WP_Customize_Manager::...
Weston Ruter's user avatar
  • 4,020

Only top scored, non community-wiki answers of a minimum length are eligible