You don’t need javascript, just change the class using the get_theme_mod variable e.g.
<?php
$layout = get_theme_mod('embee_layout_section_options[site_layout]', '3');
$class="";
if($layout == '1') {
$class="this";
} elseif($layout == '2') {
$class="that";
}
?>
<div class="<?php echo $class; ?>">
// stuff
</div>
Put that in your template file e.g. page.php and the live customizer will pick it up
Then creates the classes e.g.
.this {
float:left;
}
.that {
float:right;
}
I have built some massive complex stuff in the customizer and never had to add javascript, it’s all done through the template files and get_theme_mod
Related Posts:
- WordPress customizer: load controls in a custom div
- Customizer Show/Hide Logo and Site Title
- Get/Set wp.customize.previewer.previewUrl
- Customizer Show/Hide
- Customizer: Multiple CSS styles on same element in Live Preview
- make an array in wordpress cusmization api?
- Default Image not showing up in Customizer for WP_Customize_Cropped_Image_Control
- JqueryUi Dialog giving Uncaught TypeError: this._addClass is not a function error
- WordPress Infinite Scroll without using any plugin
- Create Image Uploader for Widget
- WordPress Ajax always returns a 404 error
- Conditionally loading JavaScript based on the Advanced Custom Fields in the post
- Is there a reason why my wordpress PHP page isn’t loading into my PHP template
- How to resize image on client-side before upload?
- Limit the Excerpt field in WP-Admin in words
- Audio Player not loading when the content is loaded through Ajax, MediaElement.js no applied
- Theme Customizer – Dynamic CSS PHP File
- Use different javascript files for each page on website
- How to get custom image size for image uploaded in Customizer
- Javascript code inside “” in core WordPress files .php
- Create custom blocks for bootstrap
- Click loads template via ajax
- Sending jsPDF documents to the server
- How can I add an alert (like the old javascript alerts) to my WP page?
- js file in root loading without
- How do I get current page ID in WordPress customizer file?
- AJAX request status 200 but no actual “response”
- Use menu link or onClick to set a variable
- From where the header-text can be changed in WordPress custom header?
- Displaying admin notices inside the block editor from rest_after_insert_{$this->post_type} hook
- Save Search System
- dynamic dependent select dropdown
- wordpress visual composer change grid builder post link
- How to pre populate a form field with a link of a current user’s author profile?
- Customizer: Category Select Sanitize
- parts of url disappear when using # inside href=”” [closed]
- PHP array to JS array to use in google map
- How to add a Custom Mailchimp AJAX Newsletter Subscribe Form
- Skt full width basic slideshow problem
- Fancybox type popup window that’s not an iframe
- how to make my website secured
- Noscript not working as it should in wordpress site
- How to correctly add Javascript to this PHP ‘Page Not Found’ Page?
- PHP echo inside javascript
- How to add API security keys into JS of wordpress securely
- get taxonomy thumbnail and use it as a variable in code
- What are the advantages/disadvantages of using jQuery DOM manipulation as opposed to PHP DOM manipulation?
- element not working in Safari [closed]
- Is it save to use eval for a jQuery callback method coming from the database?
- Get html data with javascript to php array and store to wordpress database
- An audio player that showcase a random song from playlist every 24h [closed]
- How to Change CSS Colors from Custom Plugin Settings Page
- Passing the name of selected color from the custom component to `render_callback`
- Get related product based on subcategory selected from category id with ID 142
- How to allow download url redirection only if user logged in WordPress site?
- wp_nav_menu not working correctly in my underscores theme
- wp_localize_script() and JavaScript namespaces
- Customizer: How to change Header Image description
- How can I get my Media Uploader Button to function on 1 click rather than requiring 2 clicks?
- Need advice on theme customizer and child themes
- Some problems in custom widget
- Call a function in functions.php from within tags (JS)
- WordPress – Get Posts with Category data
- How to use wp_send_json() and output the value with ajax?
- Hook on file upload
- Using Ajax to submit a form, and run a SQL Select query based on user input from the form
- How to store checkbox data for individual users?
- using shortcodes inside gravity forms
- How to call my PHP function with AJAX ? wp_query
- Gutenberg block don’t save rich text content
- Creating a POP Alert
- separate list of programs in html/javascript coming from php
- Hide Approved status for certain users in users list
- ACF values to Script with auto refresh
- How to add locations input to user profile?
- wordpress dependent dropdownlist using post type is not working
- How to echo a PHP code into WooCommerce variation product?
- Custom Post type Ajax search results
- include javascript Multiple files in wordpress through script.js
- Ajax wordpress function showing source code in alert and not value of input field?
- Full search and replace isn’t enough to make all pictures to be loaded with https
- I want url from a file in media using title file
- Find the method which AJAX GET calls
- Use Custiomizer to setup meta theme color tag
- Retrieve $_POST data to send to javascript without using localize script
- Why I’m Not Having Access to “$_POST” Data Outside My AJAX Callback?
- I need help implement a Javascript code into the PHP file
- Admin bar nodes
- How can I correctly POST to a WordPress page?
- if is_home(), change class of menu-item-225 of wp_nav_menu
- Load php function with AJAX on modal window
- JSON Object Value Show Undefine
- Require Credits Footer
- Adding jquery using php function
- Facing Problem While Running WordPress Hook For Archive, Categories, Author, Date Pages Only
- WordPress Customizer add_control Dropdown of Pages with Multi Select?
- Retrive the value of the Active variation of the product and then link it to the “read more” to dynamically change
- How to make this shortcode not refresh the whole page when i use it on frontend
- How to pass php array to external js file in WordPress
- Can’t make an external api call in php side of wordpress child theme