Articles of get theme mod

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

How to make get_theme_mod work with AJAX in the customizer preview

Is it possible to make the get_theme_mod work after refresh in the customizer preview pane when it’s being called inside a template part by AJAX? I have a theme that loads the posts on scroll (infinite scroll) and everything works except it doesn’t output the updated theme mods in the customizer preview. It only outputs […]

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’ […]

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’ => ‘’, ) ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, ‘intro-img’, array( ‘label’ => ‘Intro Image’, ‘section’ => ‘section_one’, […]

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’); // […]

get_theme_mod always returns default

I’m working on a website of a client and I’m trying to add social media links to the customizer, which then can be called through get_theme_mod, via a shortcode. However, when trying to call them, I always get the default. When I checked get_theme_mods, they didn’t seem to be defined at all… However, in the […]

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’ => […]

How to hide get_theme_mod if field empty

I’m using: get_theme_mod to show various pieces of info from the theme customizer, in the following format: <a href=” <?php get_theme_mod( $name, $default ) ?> “>This is the link</a> I would like to hide the whole line if that particular customizer field is empty. What could I wrap around the anchor to accomplish this?

Use default value of wp_customizer in theme_mod output?

Is there a way to output the default value of a wp_customize text field type using the echo get_theme_mod (); without actually going in the Theme Customizer, modifying something and then saving it? I just read on another stackexchange question that the get_theme_mod will only show something after you save it in Theme Customizer. Not […]

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?