Trying to Load jQuery

When enqueuing a script from a child theme, you have to use get_stylesheet_directory_uri rather than get_template_directory_uri(). The template directory is the parent theme, and the stylesheet directory is the one shared by the directory the active stylesheet is using. In your functions.php file, the enqueuing would be: function avtheme_scripts() { wp_enqueue_script( ‘av-about-fade’, get_stylesheet_directory_uri() . ‘/js/about-fade.js’, … Read more

How to display comments length

I used this: function wpb_countx() { wp_enqueue_script(‘jquery’); ?> <script> jQuery(function($) { // configure var comment_input = $( ‘#commentform textarea’ ); var submit_button = $( ‘#commentform .form-submit’ ); var comment_limit_chars = 1400; // stop editing here // display how many characters are left $( ‘<div class=”comment_limit_info”><span>’ + comment_limit_chars + ‘</span> zbývá znaků</div>’ ).insertAfter( comment_input ); comment_input.bind( … Read more

datepicker for custom post type admin

Issues I noticed in your code I don’t see where/how you’re calling that custom datepicker() function and you should use the same admin_enqueue_scripts hook for registering/enqueueing a stylesheet (.css) file. You should only load the CSS and JS files on the pages where the styles and scripts are being used, e.g. in your case, the … Read more

problem with jquery 3.5.1 in footer

GREAT… thank you very much. It opens my mind. I’ve tried to translate this eventListener in bind jQuery version, but I can’t. So I modified the FancyBox Jquery to read directly wp block < a href > $(“li.blocks-gallery-item figure a”).fancybox({ /* wp block version */ }); $(‘.fancybox’).fancybox({ /* fancybox default standard */ });

jQuery Show DIV and Remove Button [closed]

/* Show/Hide my div*/ jQuery(document).on(‘click’,’.my-button’,function() { //jQuery(‘.div-wordpress’).slideToggle(‘230′,’swing’,’hide’); this.remove();//supposed to be #my-button ? }); Note that I have swapped ids for classes and just made a small JS update – this is the clicked element inside a jQuery event – not jQuery(this) Here is a CodePen: https://codepen.io/qstudio/pen/PoGdLgX

Notice-Updated div moving around unprompted

Searching for .notice on WP source code I found the culprit at wp-admin/js/common.js: $( ‘div.updated, div.error, div.notice’ ).not( ‘.inline, .below-h2’ ).insertAfter( $headerEnd ); Adding an inline class to my code solves the issue: <div class=”notice updated inline”>Form sent</div>

Jquery not loaded by default in wordpress 5.6

You can ensure that jQuery is loaded by adding it to the $dependencies array when you enqueue your script. add_action( ‘wp_enqueue_scripts’, ‘wpse384152_enqueue_my_scripts’ ); function wpse384152_enqueue_my_scripts() { wp_enqueue_script( ‘my-script’, ‘/path/to/my/script.js’, array( ‘jquery’ ) ); } That will ensure that a) jQuery gets loaded and b) it gets loaded before your script. References wp_enqueue_script() Default scripts