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
- WP_Query orderby date not working
- Order by DESC, ASC in custom WP_Query
- Display products from specific category in shop page
- Secondary Sort (fallback) for WP_Query
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- Query Posts in a Predefined Order
- How do I order pages and categories by ID or name in the same query?
- WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)
- Order by meta_value_num DESC and meta_value ASC on WP 4.0
- Query by meta_key and order by meta_value_num return orderby date
- Wp_query order by multiple custom fields?
- List taxonomy terms plus their latest post ordered by post date
- WordPress altering my custom query, How to fix it?
- Order by meta_key in custom post type doesn’t affect the query
- How to create/modfiy WP_Query to search in post title OR custom field?
- WP_Query with multiple meta fields filter?
- How can I pick a single post from the latest 3?
- How to combine meta_query and post__in in WP_Query
- Order WP_Query by multiple fields, subtracting them from one another
- Meta Query Array Error 500
- Fetch Record based on meta key dates
- Sort WordPress Posts Meta value by Week not Day
- Wp_query with 2 meta keys and array of meta values
- meta_query: check if number exists
- How to order WP_Query to group results?
- Event with multiple dates, display events chronologically
- Order is breaking wp_query
- How to use a dropdown to filter posts by custom field
- Orderby two meta fields not working
- WP Query / Meta Query [duplicate]
- Query posts by searching for a string in a meta field
- Query multiple post types, but different order for each
- How to add date_query to meta_query array
- Order by the first array within a meta_query
- Query ACF relationship field – Comparator IN – Value array
- Combine query in WP_User_Query()
- Multiple nested meta queries
- How to _GET multiple value checkbox WP_Query in Custom Toxonomy / Custom Fields
- Comparing Meta Field date in WPQuery using Meta_Query?
- How to create better WP_Query to look for date time which is anywhere between two meta values?
- How to get_comments() ordered by date and parent?
- Filtering WP_Query based on wp_postmeta keys values
- datetime picker, timestamps and meta queries
- WP_Query with meta_query won’t orderby
- meta_query only check if both value are set
- Wrap group of wp query posts to parent div by date/year
- Extending WP Query: Custom geolocation meta values work, but tax_query breaks
- Show sticky post before other WP_Query
- Looking for a way to exclude frontpage and nav menu from query filter
- Creating Custom Query
- Get posts by meta value except one post [closed]
- How to get all post_id and meta_value using meta_key in wp_postmeta table
- WP Query – Show custom posts only if user contain some user meta
- How do I subquery with custom meta fields?
- Why does wp_query only display the most recent post when using order ASC?
- new WP_Query with order args – no more distinction between categories