Redirect wp_dropdown_pages() to an AJax request?

The following is the solution I came up with: <div id=”selection1″> <div id=”dropdown1″> <form id=”choice1″ action=”<?php bloginfo(‘url’); ?>” method=”get”> <?php $select = wp_dropdown_pages( array( ‘post_type’ => ‘page’, ‘show_option_none’ => ‘Select Car’, ‘echo’ => 0 ) ); echo $select; ?> </form> </div> <div id=”firstchoice”></div> </div> <script> $(‘#choice1’).change(function(){ //if the select value gets changed var png = … Read more

No Object Properties sending form through AJAX

You can try to use new FormData() instead of new FormData($(‘form#change-avatar’)[0]). Also, after processData:false you should add contentType: false since jQuery will set it incorrectly otherwise, and for url, instead of ajaxurl you should useajaxobject.ajaxurl, since with wp_localize_script, the second parameter is the javascript object name

jQuery plugin not loading

It might be the case that you are using you JS validation before enqueuing this script. You code may be like.. <html> $(“#myForm”).validate(); or JS file that uses validate() jquery.validate.js here </html> Above code is just for demonstrating. So you are using validate() function before it has been enqueued so it is throwing validate() is … Read more

Moving jQuery to footer from header

The proper way to wp_enqueue_script is : wp_enqueue_script(‘jquery’, get_template_directory_uri() . ‘/js/jquery.js’, array(), ‘1.11.3’, true); The last parameter is $in_footer set it true which will insert the script into the footer. Note: You don’t need to include jquery bcz by default it is added in WordPress.

General Settings: display custom plugin field after Site Address field

Figured it out by using the following jQuery function. The #protocol_relative is the field I am inserting and #home-description is the field I am inserting it after: add_action( ‘admin_footer’, ‘insert_field’ ); function insert_field() { # Insert the settings field after the ‘Site Address (URL)’ ?> <script type=”text/javascript”> jQuery( ‘#protocol_relative’ ).closest( ‘tr’ ).insertAfter( jQuery( ‘#home-description’ ).closest( … Read more

jQuery – Toggle megamenu submenu items by click

Try this -> jQuery(document).ready(function($) { $(‘#menu-main-menu a’).click(function( event ){ var visibleSubmenu = $(‘#menu-main-menu ul.sub-menu:visible’); var submenu = $(this).next(‘ul.sub-menu’); if( submenu.length >= 1 ) { event.preventDefault(); visibleSubmenu.slideUp(); submenu.slideToggle(); } }); });

jQuery selectable() function won’t work in wordpress

I always refer to to this blogpost about how to including jQuery code in WordPress. It shows you how to use noConflict within your javascript-code. var $j = jQuery.noConflict(); $j(function(){ // YOUR CODE HERE } } Also make sure that the jQuery library is included on the frontside of your WordPress installation with the wp_enqueue_script-function. … Read more

jQuery script doesn’t work on WordPress

Initialize the Scroll to Top script from within another JavaScript file. I’m assuming that jquery.backtotoplink.js is coming from a third party and that it should not be modified. For example, in a theme, the JavaScript could be enqueued like this: function wpse247853_scripts() { // jquery.backtotoplink.js depends on jquery wp_enqueue_script( ‘scrolltotop’, get_template_directory_uri() . ‘/js/jquery.backtotoplink.js’, array( ‘jquery’ … Read more

jQuery don’t working

Don’t load jQuery that way. It comes built into WordPress, so what you really want to do is tell WordPress that (1) your Javascript file should be loaded, and (2) it relies on jQuery being loaded. You do this with wp_enqueue_script. So put this in your functions.php file, replacing the path in quotes with the … Read more