Adding a slide toggle on WordPress

WordPress has default jQuery. So, no need to load this file explicitly. JS Code: jQuery(‘#toggle-onoff-network’).on({ ‘click’: function () { var origsrc = jQuery(this).attr(‘src’); var src=””; if (origsrc == “https://wordpress.stackexchange.com/questions/166823/img1_on.png”) src=”img2_on.png”; if (origsrc == ‘img2_on.png’) src=”https://wordpress.stackexchange.com/questions/166823/img1_on.png”; jQuery(this).attr(‘src’, src); } }); // The script jQuery( “#netywork-toggle” ).click(function() { jQuery( “#share-stuff” ).slideToggle( “slow”, function() { // Animation complete. … Read more

JQuery Plugins in WordPress

Your main issue with your code is that you aren’t wrapping your JS in a <script> element. <?php /* Template Name: Price Chart */ /** * Enqueue the table sorter script */ function load_table_sorter_scripts() { //wp_enqueue_style( ‘style-name’, get_stylesheet_uri() ); wp_enqueue_script( ‘tablesorter’, get_template_directory_uri() . ‘/js/jquery.tablesorter.min.js’, array(‘jquery’), ‘1.0.0’, true ); } add_action( ‘wp_enqueue_scripts’, ‘load_table_sorter_scripts’ ); // Now … Read more

Adding jQuery datepicker to Custom Post Type Metabox [closed]

To properly work I didn’t write my js file like you. My code will only stand for admin side not the frontend. In the js enqueue js file (date-picker.js): jQuery(document).ready(function(){ jQuery(‘.ads_datepicker’).datepicker({ dateFormat: ‘yy-mm-dd’ }); }); I enqueue my script like this add_action( ‘admin_enqueue_scripts’, array($this, ‘enqueue_date_picker’ ) ); public function enqueue_date_picker(){ wp_enqueue_script( ‘date-picker-js’, plugins_url(‘/js/date_picker.js’, __FILE__), array(‘jquery’, … Read more

Simplest ajax form not working when it should

I have been investing some quality time (and headaches) with WP ajax so I understand where you are coming from. In all honesty, it could be anything from an error in your JS code or something completely bizarre, like: add_action(‘wp_ajax_UpdateMeta’, ‘UpdateMeta’); Should be changed to: add_action(‘wp_ajax_updatemeta’, ‘UpdateMeta’); … to remove the capitals because by some … Read more

jQuery function not working

You need to wrap your jQuery click event in a DOM ready function. (function($) { $(‘.signUp’).click(function() { $(‘.signUpForm’).toggle(); }); })(jQuery);

Remove Yoast jQuery from front end

How this line (9th) is created within your theme code? <script type=”text/javascript” src=”https://wordpress.stackexchange.com/wp-content/themes/blankslate/js/jquery-1.11.1.min.js”></script> If it is hard-coded in header.php, then I would recommend to remove it. Scripts should be enqueued instead of hard-coding them. Next, you can de-register jquery.migrate script with the following code added to functions.php: /** * Remove jQuery migrate script */ add_filter( … Read more

wordpress add_action() issue in ajax call

You’re sending your AJAX request to the wrong place. Of course calling functions.php directly will get you undefined function errors, because the WordPress API isn’t loaded by functions.php ( it’s the other way round ). A car doesn’t make fuel go forward, fuel makes a car go forward, simply getting in the car won’t make … Read more

Prevent other versions of jquery from loading on static front page

Maybe I am on thin ice but lets try. Assuming that you already have the correct jquery version(you want to use) downloaded and copied to a folder. (The same js folder as the jquery.rwdImageMaps.js would be logical imho) Imho you also can delete folowing code part <script type=”text/javascript” src=”https://wordpress.stackexchange.com/questions/195723/<?php echo get_stylesheet_directory_uri(); ?>/js/jquery.rwdImageMaps.js”></script> from that front-page.php … Read more