How to make JQuery load on top of head tag before everything

The function wp_register_script has a parameter called $in_footer. Setting this to false will add the script to the head. wp_register_script( string $handle, string|bool $src, array $deps = array(), string|bool|null $ver = false, bool $in_footer = false ) In addition, if you deregister jquery, you can manually add the script in your head above wp_head(). This … Read more

How to use jQuery validation to set the search bar to accept only a specific input?

This code does the job (there is p instead of a) jQuery(function(){ jQuery(“.search-submit”).click(function(){ jQuery(“.error”).hide(); var hasError = false; var searchReg = /^[p0-9]+$/; var searchVal = jQuery(“.search-field”).val(); var searchLen = searchVal.length; var num1 = [‘1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9’]; var num0 = [‘0′,’1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9’]; if(searchLen < 3) { jQuery(“.search-field”).after(‘<span class=”error”>Enter at least 3 characters.</span>’); hasError = true; } else if(searchLen > … Read more

Finding post ID dynamically on click

What you’re looking to accomplish isn’t really pagination. That threw me off initially. You’re building a navigation that will be site-wide. If that’s the case, you can either capture the ID from the url (this is not very performant) or add the ID to the markup. This example shows you how to add the ID … Read more