Adding customizer styles with wp_add_inline_style

You can try to detect if the current used theme is a child and if so pointing the inline CSS to the right style. I didn’t tested this solution but could be a good starting point. function mytheme_enqueue_style() { wp_enqueue_style( ‘parent-theme-style’,get_template_directory_uri() . ‘/style.css’, false ); if(is_child_theme()) { wp_enqueue_style( ‘child-theme-style’, get_stylesheet_directory_uri() . ‘/style.css’, array(‘parent-theme-style’) ); } … Read more

Theme customizer – possible to disable Live Preview?

Yes, there is a way to disable the Live Preview rendering. 1] Open your theme’s functions.php file. 2] Append the following code snippet at the very end of the file: add_action( ‘customize_preview_init’, function() { die(“The customizer is disabled. Please save and preview your site on the frontend.”); }, 1); 3] Save your functions.php file. That’s … Read more

Add custom background to div in home page

Use the wp-head-callback argument to specify your own handler: add_theme_support( ‘custom-background’, array( ‘wp-head-callback’ => ‘wpse_189361_custom_background_cb’, ‘default-color’ => ‘000000’, ‘default-image’ => ‘%1$s/images/background.jpg’, )); function wpse_189361_custom_background_cb() { ob_start(); _custom_background_cb(); // Default handler $style = ob_get_clean(); $style = str_replace( ‘body.custom-background’, ‘#featured-home-image’, $style ); echo $style; }

Add/remove controls dynamically based on other settings in Customizer

Ok so you can check out my repo with some custom controls https://github.com/dingo-d/wordpress-theme-customizer-extra-custom-controls I’ve adapted the contextual controls by Weston Ruters guide here: https://make.xwp.co/2016/07/24/dependently-contextual-customizer-controls/ In my example in the repo I have the boxed body checkbox control that toggles boxed body. You’ll need to enqueue a script to put the js code in add_action( ‘customize_controls_enqueue_scripts’, … Read more

How to execute conditional script when on new customize.php (Theme Customize) screen

Okay, first, let’s set things up properly, with a callback hooked into an appropriate action hook: <?php function wpse55227_enqueue_scripts() { // Enqueue code goes here } add_action( ‘wp_head’, ‘wpse55227_enqueue_scripts’ ); ?> We’ll put all of our code in to this callback. The next step is to add our if ( ! is_admin() ) conditional wrapper: … Read more

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’, array( ‘default’ => ‘value_xyz’, ‘capability’ => ‘edit_theme_options’, ‘type’ => ‘theme_mod’, )); $wp_customize->add_control( ‘test_control’, array( ‘label’ => __(‘Text Test’, ‘themename’), ‘section’ => ‘spacious_slider_number_section1’, ‘settings’ => ‘test_setting’, )); } add_action(‘customize_register’, ‘themename_customize_register’); And to retrieve it get_theme_mod( ‘test_setting’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)