Including taxonomy in searches

First you want to make the query keys available so you can check them later: add_action( ‘init’, ‘custom_add_query_vars’ ); function custom_add_query_vars() { add_query_var( ‘location’ ); add_query_var( ‘tag’ ); } Then you want to set a tax_query by filtering the WP Query: add_filter( ‘pre_get_posts’, ‘custom_search_tax_query’ ); function custom_search_tax_query() { // check this is a search query … Read more

Custom post type order by post_title

I found the solution. When I take my first query and make it like this: <?php return [ “post_type” => [ “employees” ], “post_status” => [ “publish” ], “orderby” => [ “post_title” => “ASC” ], “posts_per_page” => “99” ]; the sorting is working. So I replaced: “orderby” => [ “post_title” ], “order” => [ “ASC” … Read more

How to search through “post title” and “tags” using WP_Query?

Try getting rid of the “0” key in your tax_query and meta_query array. $query_args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘order’ => ‘ASC’, ‘orderby’ => ‘none’, ‘posts_per_page’ => ‘100’, ‘offset’ => ‘2’, ‘page’ => ‘2’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘post_tag’, ‘field’ => ‘name’, ‘terms’ => array(‘test’), ‘operator’ => ‘IN’, ), ‘relation’ … Read more

Why isn’t comment validation working?

Add code in your theme function.php file function comment_validation_init() { if(is_single() && comments_open() ) { ?> jQuery(document).ready(function($) { $(‘#commentform’).validate({ rules: { author: { required: true, minlength: 2 }, email: { required: true, email: true }, comment: { required: true, minlength: 20 } }, messages: { author: “Please fill the required field”, email: “Please enter a … Read more