After fiddling and searching a bit I managed to have:
- ‘selected’ 10 posts on top
- ‘remaining’ posts below sorted descending by date
Unfortunately the ‘selected’ posts are in descending order … here is my query:
$args = array(
'post_type' => array( 'projekty', 'publikacje', 'wystawy', 'wyklady' ),
'post_status' => array( 'publish' ),
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'sticky_home_order',
'type' => 'numeric',
'compare' => 'NOT EXISTS'
),
array(
'key' => 'sticky_home_order',
'type' => 'numeric',
'compare' => 'EXISTS'
),
),
'orderby' => array(
'meta_value' => 'DESC',
'meta_value_num' => 'ASC',
'date' => 'DESC'
),
'posts_per_page' => 20,
'paged' => get_query_var('paged')
);
Related Posts:
- Sorting: custom query with orderby meta_value_num THEN by title
- Help ordering Post loop by two meta values
- Sorting: custom query with orderby meta_value_num THEN by title
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- How to get order of posts?
- Custom WP_Query order by post_meta and (author) user_meta
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- Order WP Query posts by custom order calculated from post meta values
- Order Posts by meta value AND published date
- How to orderby meta_value_num with dollar ($) sign
- How do I sort posts with multiple pages
- Complex Orderby Parameters: How to query with multiple orderby parameters using meta_value_num?
- pre_get_posts order by not working
- SQL: What is wrong with the following query (generated by WordPress WP_Query, ordering prices)
- How to orderby multiple meta fields if some fields are empty
- Sort wordpress custom posts based on meta value
- WP_Query: Group events by year, sorted DESC; then by date for each year group, sorted ASC
- Understanding the orderby in WP_Query?
- Order ascending is ignored in meta query?
- meta_value_num not ordering all items
- How to filter a query by multiple meta keys and order by other meta keys
- Advanced WP_Query with meta_query, orderby?
- Sorting search results with custom dropdown
- orderby ignored by wp_query
- Sort posts using multiple custom fields and menu_order in single query?
- What’s wrong with this meta query? (order by meta key, then title, doesn’t work)
- Order (by ASC) posts with meta_key so posts without values are last
- How to sort store location by specific category order in WP store locations
- How to sort wordpress posts already selected by WP_QUERY
- WordPress Query custom ordering by temporary variable
- Meta query orderby meta_value_num sorting by role first
- WP_User_Query Orderby Not Working
- Order by value of Custom Field using url string
- WP Query with meta queries
- Order 2 meta_queries differently in WP_Query?
- Sorting with meta_query and multiple, optional meta keys
- WP Query. Ordering posts by another post types meta
- wp_query sorting – one specific meta_key value at last and then sort by create date
- Display three sequential posts on each page load, without repeating previous
- Best way to Order Post in Home without a plugin
- Using orderby with 2 meta keys
- query_posts with sorting on a custom datestamp
- Sort Posts with custom meta key by default which is currently set as optional
- WP_Query with several meta_query-statements and order by meta_value
- meta_query compare > not working
- Complex Meta Query
- meta_query with relation = AND not working as expected when combining EQUALS with NOT EQUALS
- Slow wp_posts and wp_postmeta query using Advance Custom Fields
- WP Query for Multiple Post Types
- WP_Query: custom orderby (not ASC nor DESC)
- Multiple meta_query not working
- Query by meta value (add a dropdown of all values)
- Sorting Posts by Taxonomy thats not within the query’s $args
- Meta query doesn’t remove placeholder escape before query
- compare for multiple meta values for same key in wp_query
- Order Posts By Custom Field That is an array of objects
- Best way to query posts and order by relevancy to query
- datetime picker, timestamps and meta queries
- meta_query is not allowing to show posts when querying multiple arguments in a WP_Query
- WP_Query with meta_query won’t orderby
- WP Query Meta Query
- Order & Orderby clause not working with custom query
- meta_query only check if both value are set
- Speed up WP_query with meta comparing dates
- Meta Query if Values Don’t Exist
- Orderby query does not work for custom fields even with meta query
- Get posts meta_query by repater field
- Query 3 meta_key and orderby
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- Query custom meta value – post view and date meta
- What is the best way to reset a search on a meta_key / meta_value?
- Ignoring ‘a’ when sorting posts
- Saving custom fields for WP_Query to retrieve
- Slow query when selecting with large meta query or post__in
- How can I modify standard search query to include also ACF custom fields values?
- make query more simplest and in one query
- query_posts based on a meta_key
- Custom WP_query and integrating into theme file
- How to show all the associated posts with specific date of data metabox?
- WP_Query – show posts where meta value and user_email match
- Order posts by more than one variable (meta_key and publish date AND time)
- Combine WP_Query with array of custom data to single loop without breaking the pagination
- Create custom order sortby based on array of id
- Wrap group of wp query posts to parent div by date/year
- WP Meta Query at depth 2
- WP_Query returns empty if meta_query has more than 7 values
- orderby in WP_QUERY – Use the order from the Dashboard
- Is it possible to search for a string in posts OR postmeta?
- Extending WP Query: Custom geolocation meta values work, but tax_query breaks
- Sort by meta key within same day
- meta_query not working with the_content()
- Find by post_meta, then sort by post_meta, then sort by date (wp_posts)
- Query All Attachments and Order by Parent Publish Date
- WP_Query using meta_query with LIKE doesn’t return what it should
- Using custom field as ‘orderby’ value causing post grouping by publish date
- Sorting posts by meta values: 2 different orders
- Use not custom fields in get_posts() meta_query?
- Filter posts/pages by user_role array
- Order Custom Field by Price
- WP_Query with MetaQuery issue