Hook directly into query execution
In the class WP_Query, there is a hook posts_pre_query wich allow to set the result of a query before the DB call https://core.trac.wordpress.org/browser/tags/4.7.3/src/wp-includes/class-wp-query.php#L2755
In the class WP_Query, there is a hook posts_pre_query wich allow to set the result of a query before the DB call https://core.trac.wordpress.org/browser/tags/4.7.3/src/wp-includes/class-wp-query.php#L2755
wp_reset_query is for cleaning up after a query_posts call, you don’t need to call it after a standard posts loop, only if you use query_posts. Since you should never use query_posts to fetch posts from the database, you should never use this function. But How Do I Cleanup After The Main Loop? You don’t, this … Read more
I solved this using the HistoryAPI. Since my ajax returns objects that has response, html and query, I pushed the html results of the search to the history state with window.history.pushState( date_out.html, null, null); where data_out is the object returned from the ajax call. Then I added a button on the single advert page that … Read more
Finally i got answer. post_type=event&meta_query%5B0%5D%5Bkey%5D=date_short_order&meta_query%5B0%5D%5Bvalue%5D=$today&meta_query%5B0%5D%5Bcompare%5D=%3C&meta_query%5B0%5D%5Btype%5D=DATE post_type=event&meta_query%5B0%5D%5Bkey%5D=date_short_order&meta_query%5B0%5D%5Bvalue%5D=$today&meta_query%5B0%5D%5Bcompare%5D=%3C&meta_query%5B0%5D%5Btype%5D=DATE
Based on @birgire’s always-useful comments, I did write a workaround for you. What I’m doing is to first find the terms that match the search string. Then, based on the found terms I will do a query in those. function wpse_posts_by_tagname( $string ) { // Let’s find every tag that has ‘coffee’ in it’s name … Read more
See the documentation for $wpdb->prepare(). You need to pass a String, but you’re typing set @csum directly in the parameter. Your code should look like this: if ( is_user_logged_in() ) { $user = wp_get_current_user(); $balance = $wpdb->query( $wpdb->prepare( “SET @csum := (SELECT current_balance FROM exp_ten WHERE tenant_number=%d); SELECT tenant_number, transaction_amount, (@csum := @csum + transaction_amount) … Read more
First of all if any is used for post_type field there can not be any other value given in array like in the question. Below is the modified args $args = [ ‘post_type’ => array_values(get_post_types([‘public’ => true])), ‘post_status’ => [‘publish’, ‘inherit’], ‘posts_per_page’ => 10 ]; Use posts_where filter add_filter(‘posts_where’, ‘add_search_mime_types’); $query = new WP_Query( $args … Read more
You can get list with below code : <?php wp_get_archives(‘type=yearly&format=option&post_type=resources&show_post_count=true’); ?>
I am also get the issue same as you and finally I got the solution. We have to add $query->is_main_query() in IF CONDITION. if( ‘trip’ == $type && is_admin() && $pagenow==’edit.php’ && isset($_GET[‘tripstatus’]) && $_GET[‘tripstatus’] != ” && $query->is_main_query()) { $value = $_GET[‘tripstatus’]; $query->query_vars[‘meta_key’] = ‘trip_status’; $query->query_vars[‘meta_value’] = $value; } I hope it will help … Read more
adding the following fixed the issue foreach($query as $sefer){ $choices = array(); $inputs = array();