SmoothScroll not working in WordPress

Thanks to CSS Tricks, I changed the existing SmoothScroll code that came with the site to the following which worked: $(function() { $(‘a[href*=#]:not([href=#])’).click(function() { if (location.pathname.replace(/^\//,”) == this.pathname.replace(/^\//,”) && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $(‘[name=” + this.hash.slice(1) +”]’); if (target.length) { $(‘html,body’).animate({ scrollTop: target.offset().top }, 1000); … Read more

No data received

Your code is wrong. You are confusing wp_enqeue_script function and wp_enqueue_scripts action. It should be: function theme_script(){ wp_deregister_script( ‘jquery’ ); wp_register_script(‘jquery’,get_template_directory_uri().’/sliderengine/jquery.js’); wp_enqueue_script(‘jquery’); wp_register_script(‘amazingslider’,get_template_directory_uri().’/sliderengine/amazingslider.js’,array(‘jquery’)); wp_enqueue_script(‘amazingslider’); wp_register_script(‘initslider-1′,get_template_directory_uri().’/sliderengine/initslider-1.js’,array(‘jquery’)); wp_enqueue_script(‘initslider-1’); } add_action(‘wp_enqueue_scripts’,’theme_script’);

wordpress count link clicks by ip address

What would you do if the user uses a proxy and randomizes his IP address? There are numerous browser plugins to simplify that to a click of a button to download multiple times. The same goes for cookies. Aside from that you are trying to collect data that allows to identify users, which is illegal … Read more

Correct way to write jQuery functions in WordPress

As suggested in comments, this kind of error is caused by the fact that WordPress loads jquery in noconflict mode. The most common workaround is to wrap all functions in your script file: jQuery(document).ready(function($) { … scripts … } Another, more risky option is to switch off noconflict mode by starting the script file with … Read more

Front-end Ajax File Upload

I use this code to upload if ( ! function_exists( ‘wp_handle_upload’ ) ) { require_once( ABSPATH . ‘wp-admin/includes/file.php’ ); } if($_FILES[‘file’][‘name’] != ”) { $uploadedfile = $_FILES[‘file’]; $upload_overrides = array( ‘test_form’ => false ); $movefile = wp_handle_upload( $uploadedfile, $upload_overrides ); if ( $movefile && ! isset( $movefile[‘error’] ) ) { $file_url = $movefile[‘url’]; $file_url = … Read more

is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript

you can just check for the customize object, but if you absolutely need a conditional statement to determine whatever it is you need, you can do something like this: jQuery( function( $ ) { // set var var in_customizer = false; // check for wp.customize return boolean if ( typeof wp !== ‘undefined’ ) { … Read more

How to get those data using with ajax json?

There are two methods to access the object. 1. Ajax response. $.ajax({ url:”your_file.php”, type : “POST”, data : your_data, dataType: “json”, success:function(data){ // Retrieve the object var result = data[0]; // Grab username from the object console.log(result[‘username’]); }, error:function(xhr){ alert(‘Ajax request fail’); } }); 2. Server side script $yourArray = array(); $yourJson = json_encode($yourArray); $userData … Read more

scrolltop always 0, can’t trigger script

I guess body.scrollTop is deprecated in strict mode. Please use documentElement.scrollTop if in strict mode and body.scrollTop only if in quirks mode. So I would suggest you to use document.documentElement.scrollTop. also let us know when are you using this statement? show us full code and your console error if possible Please try the below code … Read more