make query more simplest and in one query

You can try this <?php $args= array( “post_type” => array(“product”, “post”, “page”), “cat” => ‘-124,-52’, “meta_query” => array( array( “key” => ‘include_newsletter_feed’, ‘value’ => “”, ‘compare’ => ‘!=’ ), ), ); $wp_query = new WP_Query($args); ?>

WordPress search form and search result through ACF field in custom taxonomy

This should hopefully help you on your way, although I’ve not fully tested it… The basic search form here which will load the site_url() with appended search query string. You should change this to better reflect your site layout such as <?php site_url( ‘search’ ); ?> (‘http://website.com/search‘). Place the Results page code within the results … Read more

Pagination not working on my archive page for a custom post type

So I got this to work by adding this function to functions.php // Custom query for events function set_posts_per_page_for_events_cpt( $query ) { if ( !is_admin() && $query->is_main_query() && is_post_type_archive( ‘events’ ) ) { // set date $currentdate = date(“Y-m-d”,mktime(0,0,0,date(“m”),date(“d”),date(“Y”))); $meta_query = array( array( ‘key’=>’event_date’, ‘compare’ => ‘>=’, ‘value’=> $currentdate, ‘type’ => ‘DATE’, ), ); $query->set(‘meta_query’, … Read more

What is the best way to reset a search on a meta_key / meta_value?

I wouldn’t push the meta query entries like that but build it more logical. So for example: $meta_query_args = array( ‘relation’ => ‘AND’ ); // assuming you want ‘AND’ search, you’re using both in your example if ( ! empty( $_POST[‘city’] ) && $_POST[‘city’] != ‘0’ ) { $meta_value_ville = $_POST[‘city’]; $meta_query_args[‘city_clause’] = array( ‘key’ … Read more

Query custom meta value – post view and date meta

@Sadia Please, try this once:: $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => ‘3’, ‘post_status’ => ‘publish’, ‘meta_key’ => ‘post_view’,// say 200 ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DSC’, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘post_view_last’,//2017-04-14 ‘value’ => date(‘Y-m-d’, strtotime(‘-7 days’)), //value of “order-date” custom field ‘compare’ => ‘>=’, //show post less than … Read more