Articles of get theme mod

Using get_theme_mod in php ajax form doesn't work

I have a form on one of my wordpress site pages which sends mail with a php file which also validate the form details. I was unable to figure out why it doesn’t work, until i found that if i remove this line: $site_name = get_theme_mod( ‘cz_pros_names_man’ ); From the php file which sends the […]

get_theme_mod outputs number when using WP_Customize_Cropped_Image_Control

I have added a few sections to the customizer but am having trouble when trying to call the image I have defined. The back end works great but when I call it using get_theme_mod it echos a two digit number, like 23. I have several sections in the theme customizer (non-images) and don’t have any […]

Theme logo metadata into template file

I’m looking to pull all of the metadata (e.g. alt, width, height) from the theme logo, which is uploaded through Appearance -> Customization into my theme template file. This is what I currently have, but it’s not working: $custom_logo_id = get_theme_mod(‘custom_logo’); if ($custom_logo_id) { $image = wp_get_attachment_image_src($custom_logo_id, ‘full’); $meta = wp_get_attachment_metadata($custom_logo_id); echo ‘<img src=”‘ . […]

Theme Customizer not displaying saved values in wp_head (CSS)

I’ve been learning hot to add theme customizer feature to a theme. Used few sources for the code and help, but chose the Codex in the end. I am using a snippet from the codex itself, slightly modified to add more settings. The only thing I’ve done was to add few more color options. I […]

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

Theme Customizer – Javascript (jQuery) update using `.load('file.php')` – Fatal Error: Call to undefined function

MY SETUP (AND CODE) WordPress Version 4.4.3 (Latest at time of writing) Installed on a local server using XAMPP I am using the WordPress Theme Customizer, and updating settings via Javascript (and jQuery). My homepage is separated into several sections, and the Theme Customizer has checkboxes to show and hide each section. When the section […]

get_theme_mod filter ignores sanitize_callback

So I’ve created some options for the theme customizer with sanitize callbacks. I want to be able to change those options with $_GET requests, but letting only valid values to pass, as they are specified in the sanitize_callback function. Here is my code: function _wp007432_customize_register( $wp_customize ) { $wp_customize->add_section( ‘section_header’ , array( ‘title’ => esc_html__(‘Header’, […]

Update Theme Location Programatically

I’ve been trying to update my theme location programmtically and while the menu gets created with menu items, the theme location never gets set. Here is what I have: function create_my_menu() { if(!is_nav_menu(‘primary-menu’)) { $menu_id = wp_create_nav_menu(‘primary-menu’); //$menu = array( ‘menu-item-type’ => ‘custom’, ‘menu-item-url’ => get_home_url(‘/’),’menu-item-title’ => ‘Home’, ‘menu-item-status’ => ‘publish’ ); $menu = get_term_by(‘name’, […]

Loop get_theme_mod

I’ve got a bunch of customizer settings set up Rather than calling individual get_theme_mod statements for each setting individually, is there a way to simplify it to loop thru them without having to explicitly write each one individually? The complete file is also setup on Gist for review <?php /** Adds the Customize page to […]

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