wp_register_script(… $in_footer = true) not working

Choose the right place in (rendering-)time First off, you are hooking at init, while you want to add your callback on wp_enqueue_script. Example: add_action( ‘wp_enqueue_script’, function() { wp_deregister_script( ‘jquery’ ); // Rest of logic } ); Staying up to date with core Also, you might want to use the correct version that core uses. I know, … Read more

Script Localization doesn’t work

Copying from the answer here regarding variable scope Variables inside a function are only available inside that function. Variables outside of functions are available anywhere outside of functions, but not inside any function. Because of that, you need to add your $translations array within the kvkoolitus_load_comment_validation function, like function kvkoolitus_load_comment_validation(){ $translations = array( ‘value1’ =>’This … Read more

How to hide unused profile fields?

You have the JS part down, in order to have this script run, you can use the add_action function and hook it to the admin_head. This will run your custom JS script in the header of the wp-admin area. Below is the code that you can add to your child theme’s function.php file. I’ve added … Read more

Retina JS not working

The documentation for Retina JS states that images need to have the data-rjs attribute set in order for them to opt in to using the script. This can be done using the third parameter of get_the_post_thumbnail() : <?php echo get_the_post_thumbnail( get_the_ID(), ‘thumbnail’, array( ‘data-rjs’ => ‘3’ ) ); ?>

Trying to integrate Zoho Campaign Form [closed]

You can add inline JavaScript using the wp_head action like so: add_action(‘wp_head’,’zoho’); function zoho() { $output=”<script type=”text/javascript”> var $ZC = jQuery.noConflict(); var trackingText=”ZCFORMVIEW’; $ZC(document).ready( function($) { $ZC(“#zc_trackCode”).val(trackingText); $ZC(“#fieldBorder”).val($ZC([changeItem=’SIGNUP_FORM_FIELD’]”).css(“border-color”)); _setOptin(false,function(th){ /*Before submit, if you want to trigger your event, “include your code here”*/ }); /*Load Captcha For this*/ loadCaptcha(‘https://campaigns.zoho.com/campaigns/CaptchaVerify.zc?mode=generate’); /*Tracking Enabled*/ trackSignupEvent(trackingText); }); </script>’; echo $output; … Read more

Preloader for a WordPress Site

You will want to put the code in the child theme, otherwise an update to the parent theme will erase it. You want the loader to be a part of the page as the document is first loaded by the browser, then use javascript to detect when the images are finished loading and remove the … Read more

Use menu link or onClick to set a variable

By this you can pass the value using ajax, you have fetch value from $_POST in your php script jQuery(document).ready(function(){ jQuery(‘.dayLink a’).click(function(){ var li_id = jQuery(this).closest(‘.dayLink’).attr(‘id’); jQuery.ajax({ url: ‘url_to_php_script’, data: {dayValue: li_id,action:call_to_ajax}, method: ‘POST’, success: function(res){ console.log(res); } }) }); }); The closing brackets were out of order. <?php if(isset($_GET[‘li_id’])){ $test = $_GET[‘li_id’]; echo $test; … Read more