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

How to get top rated posts using wp query?

Don’t worry. I have found solution for your issue. you can use below code to display 5 top rated posts based on average rating. i have created below function to get top average rated post using sql queries and wp_query functions. here is updated function for all custom post type. function top_rated_post_via_comment_of_CPT($post_per_page = 5){ global … Read more

How to merge these two post queries?

The answer is “take the array from the tax_query argument in the first query, insert it into the second and change the relation to OR”. In other words, to use a single query with the following in the arguments … (As stated before, $terms_list_ids was already generated; it contains the IDs of Company terms which … Read more