Found an answer to this.
Somehow WordPress’ own orderby isn’t fully functional when trying to order by multiple values.
I solved this by changing WP_Query to SQL Query, and including second DESC after _postmeta.meta_value+0
SELECT XXX_posts.* FROM XXX_posts
INNER JOIN XXX_postmeta ON (XXX_posts.ID = XXX_postmeta.post_id)
WHERE 1=1 AND XXX_posts.post_type="sidebar_element" AND (XXX_posts.post_status="publish") AND (XXX_postmeta.meta_key = 'sidebar_element_meta_alignment' )
GROUP BY XXX_posts.ID
ORDER BY XXX_postmeta.meta_value+0 DESC,XXX_posts.menu_order DESC
Related Posts:
- How can I sort posts by the date and a custom meta field?
- WP_Query sort by meta_value_num or date
- How do I reorder (pop and push) items from WP_Query?
- Reverse chronology of post listing
- Automatic value for custom fields for posts
- How do I correctly set up a WP-Query to only show upcoming event-posts?
- Query Posts With Over 1000 Views
- How to order posts by meta_value and title
- Query Posts by Custom Field
- how to get post order by post id wp_query?
- Create a list of posts with topic headdings
- Need to know custom code to display random and most viewed posts in wordpress posts and pages
- WP_Query custom field pass the post id
- Override WordPress core post-template.php block template
- query posts with selected post ids first
- How to get value of a selected option from select tag and use it in WP_query to filter posts?
- How do I display posts ordered by a date custom field?
- Random order of the 5 most popular posts
- My custom query is displaying random posts in random order
- Creating Ordered Query using Meta_key
- Get query result according to merged array
- WP Query between posts custom fields [duplicate]
- Order posts by separate menu order for different sub-categories
- Order by ‘s’ using WP_Query()
- Image inside the content is replaced with featured image from my older post
- How to protect pages with double authentication: password + email (in custom field)
- Adding additional data to WP_Post object
- How set featured posts using checkbox in post edit screen?
- WP_Query: Why is sticky post not first item in loop?
- Convert custom fields to post categories
- Query posts from current year
- Most viewed post for the last 2 days using WP_Query
- Adding Post Counts to Menu (Nav) Programmatically?
- This AJAX Code Doesn’t Work – Looking for elegant solution
- How to add posts to wp_query result?
- Posts for next month
- Order post by year DESC and month ASC
- Replace Main Query With Custom Query
- Populating a page with content from post custom fields
- Hide Post comments when displayed via WP_Query
- Autoremove empty custom fields
- Group posts by year in loop
- Change Order of Admin Posts Depending on Meta
- wp query with dynamic taxonomies and terms?
- Blogroll – Different layout for first post
- How do I use `posts_distinct` correctly?
- Loop through all product posts?
- How to find what index page a post is on?
- Get Posts that are in the current month or later
- WP Query to Get Array of Slugs
- is there a way to show the the post title after the image?
- How to display Common posts from specific Tag & Category with Shortcode
- How to filter my search in post if contains a word in title, content or excerpt?
- How to return another post than requested
- Is there a way to notify specific users when new posts are published to specific pages?
- Random ajax load only works with posts_per_page set to -1
- MySql query to get posts with all meta and terms
- Query posts and return XML
- List authors with the last post title and order by last post date
- WordPress query_posts by tag doesn’t work anymore(?)
- Ignore latest two posts
- Print out last 3 blogposts
- How can I add a box to edit Order on a regular post?
- How to group only VISIBLE posts? [closed]
- Shortcode with ‘year’ parameter
- On what hook can I get the queried object’s final state?
- Add two custom fields as a default to the “new post” page.
- how to handle the loop using filling bootstrap grid structure?
- Get all custom posts with a certain taxonomy
- Link to date_query results in WordPress
- When WP_Query only returns 1 post, how do I automatically redirect to that post?
- Limiting post list by taxonomy
- How to display WP Query filters?
- Finding a post’s slug
- Order posts by date
- Will multiple category descriptions effect my search engine optimization?
- Post picker custom field on page
- Display Parent-Child Posts in specific order by comparing IDs in array
- Function is printing twice – any suggestions?
- SEARCH QUERIES – REVERSE OUTPUT
- How to use two query result together in one loop
- show loop id post , only first id can read
- filter posts based on menu_order
- Change archive results based on GET request
- Wp_query loop is not working as it should
- Show all posts from the tags without having to set all of them
- Is there a global page/post/product/anything ID?
- Auto populate custom fields by post date
- ACF Relationship – Get Parent’s Post Object
- wp query custom orderby not custom field
- Order Custom Field by Price
- Calling specific page with wp query
- Update Post with Modified Data
- The next_posts_link() works only with original $wp_query
- wp_query select if have comments
- Limit amount of pages shown in pagination within wp_query
- How to make a local “scroll to ID” on post?
- Custom Admin Post Column change order
- post loop with different design depending on post
- Sort wp_query of two post types using meta datefield for one and date for the other – possible?