For meta_query with ACF and ordering price by ASC or DESC try following code.
$args = array(
'post_type' => 'property',
'posts_per_page' => -1,
'meta_key' => 'price',
'orderby' => 'meta_value_num',
'order' => $_GET['orderby'],
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'contract',
'value' => $_GET['contract'],
),
array(
'key' => 'rooms',
'value' => $_GET['rooms'],
),
...
),
);
$query = new WP_Query($args);
if($query->have_posts()) :
while($query->have_posts()) : $query->the_post();
// your code
endwhile;
endif;
Related Posts:
- Filtering a WP_Query meta_query by numeric values isn’t working
- Meta Query “IN” doesn’t work with ACF checkbox filter
- Stuck in Order by more then one
- Meta Query Not Returning Output Despite Having Matching Values
- Query based on custom fields start and end date
- Using WP meta query to show custom post types by a start and finish date
- Query posts by current ACF meta key value on single page as related posts
- ACF meta_key and meta_value break loop
- Using meta_query, how can i filter by a custom field and order by another one?
- WP_Query orderby custom field then post_date in one query
- Populate a ACF Select Dropdown from Custom Post Type
- Querying custom post type with 2 custom fields (date-range)
- Filter a custom field based on selection of another custom field (ACF) [closed]
- WordPress Search documentation: how to improve search query using taxonomy terms, custom meta fields?
- filter search result with custom post type meta key
- Using Query Posts With Multiple Post Types And A Taxonomy
- Retrieve a specific field from taxonomy term through advanced custom fields [closed]
- Count custom post types with a specific meta value
- Can’t sort order of wp_query with 2 meta keys
- Display posts if a custom field value is equal to another custom field value
- ACF Upload Image in repeater from front-end with custom form? – add_post_meta()
- Filtering by Post Meta Custom Fields – Performance
- Ignore sticky posts if post is not in meta query
- Query that joins the postmeta table twice
- Rewrite WordPress URL to show CPT meta field data
- Multiple ACF Repeaters within a Custom Post Type
- How to change post featured image using a custom field of category?
- Sorting Custom Post Type by Meta Value but wont display when set to 0
- Returning a list of custom post types excluding those without a specific meta_value
- Custom fields vs. Custom post types for a Portfolio Website
- Get posts between custom dates
- Add custom ID to CPT posts only create not update
- WP_Query order by custom field, then randomly order some of results
- Display a CPT based on a metabox selection
- A method for ordering mixed dates in search result loop (theory only, no actual code)
- How to do WP_Query with two meta fields with orderby clause
- WP Meta query for a custom post type based on two values
- How to render a custom post type template with custom fields using shortcode
- How to query WordPress posts bycustom field with a max characters’ length
- Custom Post Types vs. Advanced Custom Fields (with Repeater Field add-on)
- Specific routing for CPT
- How To Import CPT With Only Few TEXT ACF Fields From Front End?
- ACF repeater field usage
- List of users that clicked a ‘Join’ button at single post
- Getting a custom post’s custom field based on another custom post’s custom field select
- set_query_params using custom params defined in functions file?
- Get category if used in a custom post type
- How to define the template for custom posts?
- Batch Extract Date from post title and put into ACF custom field
- Query entries from custom post type in an ACF flexible content field
- If meta_value of meta_key is less than today’s date update meta key
- How to export custom post type with ACF to individual file with automation?
- Query Posts, order by meta value
- WordPress giving a 404 page when passing a year argument different than the current year
- ACF Relationship Posts how to show additional content
- Limit search field to just search a custom post type with custom fields
- Custom field with Types: get custom field’s value label (of type select)
- Show posts associated with ACF post object and custom post type
- How can i show ACF in post excerpts
- Create if else for post types in WP_Query ‘post__in’ values
- Grouping custom wordpress post types by acf value
- Set Post Private if no linked Post Objects (ACF)
- Show in an entry a Custom Post Type associated to a post
- CPT email notification including only new value custom fields
- How to display posts with plugin (advanced custom fields) field groups?
- WordPress – display relationship between blog posts and custom posts
- Same custom post type with different ACF
- Custom sorting in post columns by ACF Pro Select Field
- meta_query Where the key value is stored as an array
- Load info from customposttype into template page
- Subpages URLs for Custom Post Type
- search results to show individual ACF fields from inside custom posts
- Videos Post Type with Custom Filters
- How to show link to product in custom fields?
- Sort custom post archives by a meta value from a different custom post type?
- In the admin, how can you list thumbnails instead of titles for a custom post type?
- Use output of wp_dropdown_categories($args)
- How to get the posts that my following users are liked?
- Looping through image object using ACF and CPT UI [SOLVED]
- Sort loop by custom field from different post type
- Meta_query by date for Events archive
- Values show up in custom home page but not in custom post pages
- Display related post content and custom field content
- WordPress page not showing up – replaced with last 10 posts?
- Showing custom post user wise with different color in wordpress
- How to load custom post type plugin after acf options page (or get settings from there another way)?
- Filter Content on all Post Types
- Advanced Custom Fields – Add Field to Specific Page [closed]
- $post breaking container loop
- Selecting posts older than the current Unix epoch timestamp
- Collection of fields in a single post
- Querying meta values within an array
- using a template for more then 1 page
- Retrieve a post with its ACF repeater fields in wordpress
- Why custom search engine only searches in post titles of custom posts?
- WP_Query() displaying past post / event
- WP Query Conditionally query meta and taxonomy
- Post object GUID adding http:/
- Display custom post type attached media file sizes
- Meta_query question