How to hook CSS file according to theme selection in the customizer section

You can access Customizer values with get_theme_mod(), so you just need to check the value of your setting before enqueueing stylesheets the normal way: function wpse_310123_enqueue_scheme_css() { $scheme = get_theme_mod( ‘theme_scheme’ ); if ( $scheme === ‘green’ ) { wp_enqueue_style( ‘theme-green’, get_theme_file_uri( ‘green.css’ ) ); } elseif ( $scheme === ‘blue’) { wp_enqueue_style( ‘theme-blue’, get_theme_file_uri( … Read more

wordpress custom theme import and export options for sample data [closed]

You don’t have to export and import the tables from the database; you don’t have to build an export/import function for your theme either. There is an Export tool built in WordPress under the Tools menu and in the same sub-menu you’ll find the Import tool as well. The process is pretty straightforward: export the … Read more

How can a default site icon be set in customizer?

You can see the customizer API to set default icon. This should do the trick, I guess: function mytheme_customize_register( $wp_customize ) { $wp_customize->add_setting( ‘site_icon’ , array( ‘default’ => get_bloginfo(‘template_url’) . ‘/images/logo.png’, ) ); } add_action( ‘customize_register’, ‘mytheme_customize_register’ );

How to load some jquery code to make validation in the theme customizer?

Create a /js subfolder in your theme directory, if such does not exist already. Save your script to a file in said folder. Then, in functions.php: if ( is_admin() ) { global $pagenow; if ( ‘customize.php’ === $pagenow ) { add_action( ‘admin_enqueue_scripts’, ‘wpse107236_enqueue_customizer_script’ ); } } function wpse107236_enqueue_customizer_script() { wp_enqueue_script( ‘your-script-handle’, get_template_directory_uri . ‘/js/your-script.js’, array( … Read more