Crop image from get_theme_mod Customizer field

I’m using the following code to allow a user to upload a custom image (in addition to header image) through the customizer. Is there a way to crop the image when displaying it? $wp_customize->add_setting( ‘intro-img’, array ( ‘default’ => ‘http://example.com/image.png’, ) ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, ‘intro-img’, array( ‘label’ => ‘Intro Image’, ‘section’ => ‘section_one’, … Read more

Why does get_theme_mod return blank (or default value) but get_option returns saved value?

Why does get_theme_mod return blank (or the default value if specified) but get_option returns the correct (saved) value? I have a colour picker in the customizer color-primary which functions correctly and saves selected value to the database, however, get_theme_mod returns blank while get_option returns the saved value. echo get_option(‘color-primary’); //returns saved value echo get_theme_mod(‘color-primary’); // … Read more

get_theme_mod not working

For some reason I cannot output the color. Everything works, but text_color just doesn’t want to output its value. What is going wrong? Back end code (functions.php): $wp_customize->add_setting(‘text_color’, array( ‘default’ => ‘#fff’, ‘sanitize_callback’ => ‘sanitize_hex_color’, ‘type’ => ‘option’, )); $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, ‘text_color’, array( ‘label’ => __(‘Text color’, ‘pc’), ‘section’ => ‘colors’, ‘settings’ => ‘text_color’, … Read more

if has theme mod

Does someone know how to write the next line in wordpress PHP, because i’m not that great with PHP. If_theme_mode has content echo { my content } else { other content }; thnx 2 Answers 2 try this code: if( get_theme_mod(‘your_setting_name’) ){ //your code }else{ //your code } Note: get_theme_mod() return false if no value … Read more

Get_theme_mod not retrieving value

I’m using the WordPress customizer feature to configure my theme and I constantly bumping into the same annoying issue, sometimes I don’t get any value from get_theme_mod while I see the effect of my change in the preview window. Here is some code: $active_type=”home”; $wp_customize->add_setting($active_type.’_categories_max’,array( ‘default’ => ’10’, ‘transport’ => ‘refresh’ )); $wp_customize->add_control( $active_type.’_categories_max’,array( ‘type’ … Read more

Theme customizer: How do you grab the value later?

I’m working on a custom site, doing all my work in a child theme. I need to add one variable, slider speed, to the customize control system. I’ve been able to modify the custom controls via the following additions to my child-theme functions.php file: function Primm_customize_register( $wp_customize ) { $wp_customize->add_section( ‘primm_section’ , array( ‘title’ => … Read more

customize_register with Multiple controls/settings – how to get values?

PHP newbie here, and I have this on my functions.php function mcs_social($wp_customize){ $wp_customize->add_section(‘mcs_social_handle’, array( ‘title’ => __(‘Social Network Handles’, ‘mcs’), ‘description’ => ‘i.e., Acme Company\’s Facebook is https://facebook.com/acmecompany then enter “acmecompany”‘, ‘priority’ => 70, )); // ============================= // = Facebook = // ============================= $wp_customize->add_setting(‘mcs_fb_op’, array( ‘default’ => ”, ‘capability’ => ‘edit_theme_options’, ‘type’ => ‘option’, )); … Read more

get_theme_mod doesn’t return the theme customizer preview’s new values in after_setup_theme hook

If I print the value of get_theme_mod( ‘enable_sleek_header’, false ) it is always the previously saved value. If I print the same thing in the header of the theme, it returns the value from customizer. Is it the expected behaviour? Am I using the wrong hook? Thanks <?php add_action( ‘after_setup_theme’, ‘pagespeed_register_menus’ ); function pagespeed_register_menus() { … Read more

Can I create customizer setting that can handle plugin shortcode?

Can I create a customizer setting which will handle a shortcode from a plugin? Do I violate and rules or guidelines in WordPress theme development? If it’s possible what is the best way to sanitize the shortcode data from my customizer setting? 1 Answer 1 It’s probably best to render the shortcode on output by … Read more