You need 'order_by' => 'post__in'
in the last query in order to “Preserve post ID order given in the post__in array (available with Version 3.5).”.
I don’t know if the order you are passing in is the order you want after the array_merge( $group_1, $group_2)
. In other words, you need to feed that second query an ordered set of ID
s and you don’t seem to be doing that.
I also can’t tell if one or the meta_key
s you’ve already queried is what you want to orderby
. Possibly something like this will work:
$the_query = new WP_Query(
array(
'post__in' => array_merge( $group_1, $group_2),
'meta_key' => 'your_date_field_key',
'orderby' => 'meta_value',
)
);
That is completely untested. Possibly buggy. Caveat emptor. No refunds.
Related Posts:
- WP_Query – Order results by meta value
- ORDER BY custom field value
- Sort posts by custom field numeric value using dropdown
- Trying to perform complex custom field query with order by set to field value
- Order Posts by Closest Numeric Values
- Is there a way to do multiple ordering on a multiple meta_query?
- Order by custom field date with ASC order
- Order Custom post type loop by custom field (datepicker)
- Sorting within nested queries / multiple meta keys
- Ordering posts by anniversary using only day and month
- Order by Custom Field date not recognized
- Comments form custom fields order
- If value present, order posts by two consecutive custom fields
- Sorting posts by multiple values, combined
- Sorting posts by custom fields in meta_query
- Order RSS content by an advanced custom field value
- Alter main archive, to show posts with meta as last
- Trying to sort and display categories(not posts) by custom field: ‘order’
- Change order of posts
- Meta query with multiple custom fields for archives page ordering problem
- Ordering posts by custom field named “date” in backend
- query posts custom field calculation value
- WP Query – Is this correct?
- Using abs() with custom field in orderby statement
- ORDER BY custom field value out of where clause
- Sortable Custom Columns not sorting correct
- Order custom fields alphabetically
- Ordering by ‘Title’ OR ‘Custom Field’
- Problem with writting correctly a query posts args in WordPress
- How to query posts by month based on date custom field?
- Ordering by ACF custom field vaule
- Sort by an ACF field in a tax_query
- WordPress Admin – Automatically Sort Custom Posts by Custom Field Date Value in d-m-Y Fomat
- (woocommerce) How to get product id form order id & then retrieve custom meta linked to product?
- How to properly get popular Posts by multiple Values
- Order a query by meta_value and then by post_date
- Can’t sort custom column on user.php by number / meta_value_num?
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Individual Widgets per Page
- Add custom fields to search
- How to add add_meta_box to specific Page Template?
- How to get users by a custom field / by user meta data?
- Auto sort the wp-admin post list by a meta key
- Add custom field to image editor
- Show User Their Password
- TinyMCE in Custom Metabox not loaded after upgrading from WP 3.1.4 to WP 3.2
- How to reload the role specific registration form on validation errors?
- ajax delete value from custom field array
- How can I sort get_users() by any value (last_name, user defined fields and more)
- Custom field for default gallery
- After moving my site from a dev subdomain, to root, all my custom meta data is gone
- Gravity Forms: Create fields programmatically
- WordPress Custom Field Should be Unique. Is it possible?
- all tincymce’s switch when updating page after changing from html to text in custom metabox
- Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]
- Order Posts by meta value AND published date
- List custom taxonomy terms from custom field
- How do I create a column in Users list and display user data from custom registration field
- Better Method for Multiple Meta Boxes
- Possible to add a meta field for css attribute to the editor Advanced panel?
- Product Custom Fields with HTML and JS
- Add new image block, set default class name and update it using Javascript
- Add image to menu item with ACF
- Client PDF Upload (Catalogue) – Automatically update link to PDF
- How to load an assets based on custom field value?
- Adding auto-complete to custom gravity field not working
- Search in Archive Pages by subcategory, tag, custom field and year
- Get image url using image id
- Create a list of posts with topic headdings
- Using a custom field inside a shortocde
- Add Custom Profile Field as Notes
- Increment user meta data by 1 each time a page is visited
- Woocommerce frontend edit custom fields
- Can’t Output get_post_meta?
- Displaying an ACF list of users
- Meta value Array
- using custom fields on content.php file of my theme
- Hide / Show Custom field depending of the page ID (Magic Field 2)
- How to show certain data on certain interval of period
- How do I include a template file while allowing it to render its own dynamic content added via custom box?
- Counting post fields
- add_comment_meta not working properly
- how to enable custom fields in the Gutenberg post editor
- Missing Custom Fields
- Automatically Add Tags Taxonomy in Post from Custom field’s value
- How to get data from user meta custom fields created with acf-pro plugin?
- How to I change the value of a custom field on the home page?
- Get custom field outside wordpress loop on new php page
- Query Posts based on custom field value
- Group pages by custom field values
- 404 on Pages for Custom Post Type & Query_Posts
- Convert many posts from having a specific meta_key to use a post_format
- Custom fields: my custom checkbox area doesn’t seem to work
- How to check if custom field exists in this widget query
- display loop only if a post meta data exist
- Add Custom field under the post title [closed]
- Check if a field is capitalized?
- Need to call this php function inside a modal window from text widget
- Dynamically update Custom Fields to display new dates
- save all acf options in one meta_value [closed]