You need to use a meta query:
if ( isset( $_REQUEST['src'] ) ) {
$query = array(
'post_type' => 'post',
'meta_query' => array(
),
);
if ( isset( $_REQUEST['srcbusiness'] ) ) {
$query['category_name'] = wp_unslash( $_REQUEST['srcbusiness'] );
}
$fields = array(
'srctype',
'srcprice',
'srccity',
'srcdistrict',
);
foreach ( $fields as $field ) {
if ( isset( $_REQUEST[ $field ] ) ) {
$meta_query[] = array(
'key' => $field,
'value' => wp_unslash( $_REQUEST[ $field ] ),
);
}
}
}
Related Posts:
- Page template query with WP_Query
- How to display page content in a page template?
- get_queried_object() returns null on post date archive
- Display List Of Posts Containing a Relationship Field Value [ACF]
- How to clear the cache?
- What to do in this case after wp_query has been modified
- Exclude comments from a WP_Query object?
- Get the number of posts from the current page results
- How to get random posts and order them by date
- Get WooCommerce best selling products for the current month [closed]
- When should you use wp_reset_postdata vs wp_reset_query?
- Post queries by latitude and longitude
- WP API to fetch all the media/posts records if count is more than 100
- How to use global post counter in the loop?
- WP Meta Query for some meta (array) values
- Front End Sorting Questions
- How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?
- Meta_query with or without value
- How can I query posts from multiple roles?
- WP_Query Filtred by author name ( Return null )
- How to add terms to my tax_query based off of the current post
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- Using $paged redirects /page/2 to page 1
- Why wont this wp_query exclude certain pages?
- How do I change database charset when using `wpdb`
- WP_Query attachments by multiple IDs
- get_posts – get all posts by array of author
- wp_query not searching with apostrophe
- pre_get_posts Remove tax_query Completely
- Query “Category A” + 1 post from “Category B” – how?
- How to combine two or more WP_Query?
- Assigning a meta_query value based on regexp to wp_query fails
- Getting Taxonomy inside WP_Query Loop
- Nested tax_query that allows specified categories OR tags, but NOT other categories
- How to delete taxonomy term when a wordpress user is removed?
- Custom query based on meta key – Reduce three states to two in results?
- WP_Query custom query showing only 10 posts on all pages
- Not getting metavalue
- Ajax load more posts – WP_Query parameters not working
- How to display multiple custom fields with the same meta_key in an ascending order?
- Using the_post_thumbnail resets current loop item ID
- Meta_query with multiple keys and multiple values
- WordPress WP_Query make mysql time out
- Posts not showing per category after WP_Query?
- wp_query exclude word and category
- Assign Json file to WP_Query
- How can I query users by custom role?
- How do I query for posts by partial meta key?
- WP Query to have sticky posts first, with pagination and having a joint ‘posts per page’ arg with main loop
- New WP_Query calls Pre_get_posts filter twice
- How to increase load time of an archive/search page (WP_Query)
- Removing duplicate values between two wordpress queries
- Issue with front page navigation after upgrading to 3.4
- Ordering posts by an array
- Prevent author bio page from showing in search results
- Changing the default wp_search_stopwords
- Exclude recently updated post from custom WP_Query using multiple loops
- get_posts output always same post
- WordPress Custom Search Form Displaying Unexpected Results
- WP_Query array key / value pairs?
- Get posts from multiple tax terms
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- Limit number of posts in loop
- How do I get Woocommerce product variation name and variation description in a WP_Query?
- WP_Query offset is returning post from prevois loop
- Tax query is not working!
- Does WP_Query ‘responds’ badly to empty arguments?
- Does putting queries within loops cause an issue on WordPress?
- How to create Page templates for showing Blog posts in different layouts?
- Determining what post is displayed out of total posts found
- Reordering content using a meta value
- Adding query parameter to archive page returns 404
- Optimising WP_Query with ACF Fields
- Is it normal that get_post() gets run 300 times and the content of those posts aren’t visible?
- WordPress AJAX Request returns 400
- Using wpdb prepare with a variable, turns it into a big string
- WordPress Sub Category Archive, Show Extra Empty Page Number in Pagination
- SQL to join u3g_users & u3g_meta_value with repeating data
- WP_Query no result if keyword contains number
- How to get meta key list efficiently?
- Order by value of Custom Field using url string
- Get posts having meta value between two numbers
- update_post_meta performance in a loop woocommerce
- Separate by Category Post Type
- ACF: using two loops, the_field returns field content from another loop
- Using modified ‘meta_key’ to set ‘orderby’ in WP_Query?
- Combine WP_Query with array of custom data to single loop without breaking the pagination
- query_posts() doesn’t seem to be called in my page
- Query posts in current category but not attachment format
- WP_Query with Pagination and orderby meta_value_num showing duplicates
- why is this query returning entire blog-posts
- Pagination error WordPress multiple loop
- Multiple wp_query loops showing first 5 posts on all pages instead of older posts[Resolved]
- get_posts works but new wp_query doesn’t
- SQL returned by Wp_Query has wp_posts.ID = -1
- $query conflicting with other queries in the same page
- How to sort by post_date and meta_value_num?
- Filter posts by category
- Search query alteration not working for meta values
- WP_query shortcode inside acf Repeater breaks the repeater loop