Invoking Jquery in a Plugin

To load default wordpess jquery you can use this add_action( ‘wp_enqueue_scripts’, ‘my_jquery’ ); function my_jquery(){ wp_enqueue_script(“jquery”); } And use jquery no conflict wrapper to avoid error or on your jquery code (function($) { // Inside of this function, $() will work as an alias for jQuery() // and other libraries also using $ will not … Read more

Creating a new div onclick wordpress+ajax

To add action for WordPress AJAX If you needed to create an AJAX handler for an “render_admin_charts_page” request, you would create a hook like this: add_action( ‘wp_ajax_render_admin_charts_page’, ‘yourfunction’ ); function yourfunction() { ?> <div class=”wrap”> <div class=”em-bookings-events”> <h2><?php esc_html_e(‘Event Booking Report’,’dbem’); ?></h2> <?php em_bookings_events_table(); ?> </div> </div> <?php // Handle request then generate response using … Read more

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

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);

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)