Removing auto versioning of JS and loading to header

If I’m reading correctly you just want to deregister a script but failed… I think that you tried to deregister it too early( before was added ). add_action( ‘wp_print_scripts’, ‘example’ ); function example() { wp_dequeue_script( ‘name_of_script’ ); } By calling the function in ‘wp_print_scripts’ should be fine, which is latter than ‘wp_enqueue_scripts’, where you usually … Read more

Cannot set property ‘className’ of null at setThemeFromCookie

Using JQuery Simplifies the whole thing, using JS Cookie $(document).ready(function(){ // Check cookie and set theme if(Cookies.get(‘theme’)) { $(‘body’).removeClass(‘light-mode dark-mode’).addClass( Cookies.get(‘theme’) ); }; //Switch theme and create the cookie… $(“#theme-toggler”).click(function(){ if ($(‘body’).hasClass( ‘light-mode’)){ $(‘body’).removeClass(‘light-mode’).addClass(‘dark-mode’); Cookies.set(‘theme’, ‘dark-mode’); }else { $(‘body’).removeClass(‘dark-mode’).addClass(‘light-mode’); Cookies.set(‘theme’, ‘light-mode’); } }); }); Add id to button. <button id=”theme-toggler” type=”button” name=”dark_light” title=”Toggle dark/light mode”>🌛</button> … Read more

Where to upload JavaScript file in WordPress

Yes. You will want to enqueue your scripts using wp_enqueue_scripts and then upload them into your child theme. I normally create a /js/ directory to keep things organized. Here is a sample of how to enqueue a file inside of a themes JS subfolder. function wpse_enqueue_scripts() { wp_enqueue_script( ‘js-functions’, get_stylesheet_directory_uri() . ‘/js/functions.js’, array(‘jquery’), filemtime(get_stylesheet_directory() . … Read more

Add Codepen animation as Preloader to WordPress

1) In which location should I add the codepen html code? If you’re using a child theme, then for example, you could copy parent theme header.php file to your child theme directory and add the required html to that file after <head>. If you’re developing your own theme, then put the markup wherever you want … Read more

How to execute Javascript on a WordPress page?

<?php function enqueue_javascript_for_certain_page() { $page_id = 100; // change this to fit your needs if ( is_page( $page_id ) ) { // check the page you are on wp_enqueue_script( ‘my_script_name’, // script handle get_template_directory_uri() . ‘/js/my-js-file.js’, // script URI array( // your script is dependent on following: ‘jquery’, ‘jquery-ui’ ), NULL, // script version (NULL … Read more

What are the advantages/disadvantages of using jQuery DOM manipulation as opposed to PHP DOM manipulation?

PHP is running on the server, JavaScript in the client. This means PHP is faster (more resources), the result can be cached, and you have to test only one interpreter. JavaScript – you don’t really need jQuery for this – is more error prone, because of weird clients, blocked resources, or a more limited available … Read more

get taxonomy thumbnail and use it as a variable in code

You have ‘taxonomy’ => ‘product_cat’ in your code, so most likely you have Woocommerce, and we need to get a category picture from there. Try this code <?php $args = array( ‘taxonomy’ => ‘product_cat’, ‘title_li’ => ”, ‘hide_empty’ => 0, ‘echo’ => 0, ‘show_count’ => 0, ‘style’ => ”, ‘parent’ => 0 ); $get_cats = … Read more