infinite loop in wp_query using simple query

I’m not certain why it would cause an infinite loop, but make sure not to use $wp_query as the variable name for your custom query. It’s a reserved global variable for the main query. Use a different name for the variable. I’d also suggest using wp_reset_postdata() after the loop: $my_query = new WP_Query( $args ); … Read more

Merge two search functions for custom post type

Your functions are already simple enough, and secondly, the functions do different things: _s_staff_query() filters the posts query variables and the function has to run before WP_Query queries the database. _s_staff_search() filters the search results template and the function has to run after WP_Query queries the database. So just keep them independent.

Individual months in WP Query

It’s possible to pass multiple sets of arguments to date_query, so if you set relation to OR for them, you should get posts that match either, meaning that you could get the posts you want like this: ‘date_query’ => [ ‘relation’ => ‘OR’, [ ‘month’ => 1, ‘year’ => 2019, ], [ ‘month’ => 5, … Read more

All posts returned when author of 0 is queried

Welcome to WPSE. The condition you want to prevent is a ID of 0 so only run the query if it does not. Also, DRY – don’t repeat yourself. Rather than call get_current_user_id() multiple times, call it once and store it. $reg_count= 0; $user_id = get_current_user_id(); if ( 0 !== $user_id ) { echo “looking … Read more

Custom WP query with polylang term

Revised Answer If the terms 2, 32, 71 and 38 belong in the same taxonomy like language, then see my original answer. Otherwise, the WP_Query would be like so: $query = new WP_Query( [ ‘post_type’ => ‘property’, ‘tax_query’ => [ ‘relation’ => ‘AND’, // for clauses 1 and 2 [ // clause 1 ‘taxonomy’ => … Read more

how update data through ajax and jquery

First of all, in your jquery event handler the action parameter’s value should be the string after wp_ajax_ and wp_ajax_nopriv_. So in your example the action should be update_records. So display_func is wrong. Then in line 3 of your php code here the echo keyword should be removed. So your php code should be like … Read more