get_theme_mode & set_theme_mode in block editor
get_theme_mode & set_theme_mode in block editor
get_theme_mode & set_theme_mode in block editor
The examples you’ve seen are out of date. From WordPress 4.5, released in 2016, the proper way to support a custom logo was to register support for the Custom Logo feature in your theme. That link has the full documentation, but the short version is that you use this code to enable the standard logo … Read more
The function get_theme_mod() returns information. Since you want to assign it and not echo it to the screen, we can remove the echo and PHP tags: $args = array( ‘post_type’ => ‘product’, ‘stock’ => 1, ‘posts_per_page’ => 4, ‘product_cat’ => get_theme_mod( ‘vatname’, ‘Clothing’ ), ‘orderby’ =>’date’, ‘order’ => ‘ASC’ ); That should fix your query. … Read more
If the theme mod option has a value in database, your code is working just fine as it should return the value in database and ignore the second parameter. The second parameter is the default value to be used if there is no value is set. And the value is stored in database. The problem … Read more
Why don’t you create a JavaScript which will listen for change. When you click what you should click you just change the CSS with JS or add some class. So like that when you click SAVE it will work and you will have live preview.
Change this ‘group1’ => __( ‘Group 1’, ‘ctotheme’ ), To this ‘Group 1’ => __( ‘Group 1’, ‘ctotheme’ ), The first text ‘group1’ is the value the second is the label for the select option
I answered my own question. I had the defaults set in the customizer settings, but not in the get_theme_mod() function.
It seems that the problem was that I was adding the function to ‘init’ and where the preview was not updated. Adding it to wp_enqueue_script solved my issue. Changed add_action(‘init’, ‘autoCompileLess’); to add_action(‘wp_enqueue_scripts’, ‘autoCompileLess’);
Here is a modified version of your original code. Your echo statement isn’t right and really isn’t necessary. It’s probably better to jump out of PHP like I’ve done in the code below. Also, the unnecessary else statement was removed: <?php $servicescontent = get_theme_mod( ‘services-page’, 1 ); $abc = get_theme_mod( ‘services-check’, 1 ); $mod = … Read more
Correct was to customise theme using get_theme_mod in scripts