You can get all posts by using a meta_query
that gets posts where the key either does or does not exist, and then order on meta key with a secondary order for posts with same value or no key:
$args = array(
'post_type' => 'my_product'
'tax_query' => array(
array(
'taxonomy' => 'my_product_cat',
'field' => 'slug',
'terms' => array( $category->slug )
)
),
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'vip_row',
'compare' => 'NOT EXISTS',
),
array(
'key' => 'vip_row'
'compare' => 'EXISTS',
)
),
'orderby' => array(
'meta_value_num' => 'DESC',
'date' => 'ASC',
)
);
$query = new WP_Query($args);
Related Posts:
- WP_query parameters for date range
- ACF: post query, hide duplicate values [closed]
- Performance considerations – postmeta table versus new table for custom posts with foreign keys?
- WP-Snap too slow (caused by WP_Query?)
- Multiple instances of nivo slider plugin
- DROP TABLE with uninstall hook not working
- How to change this WP_Query to get all ProductIDs and not only specific one?
- How to call WordPress function other files
- Insert content of a post into another
- WP_Query and NULL meta keys
- how to use in custom single.php template using php?
- WordPress page and plugin list using sql query
- How to create a custom shortcode based on the layout?
- Using AJAX to generate front end / viewer end pages
- background images WP Supersized on homepage
- WooCommerce search products between price range using WP_Query
- Redirect to another page using contact form 7? [closed]
- How to insert multiple postmeta values with one query?
- How to Loop Through all Posts and Count Attachments using Get Media Attachments
- Render content of multiple pages and their descendants
- How to get a list of bundled products using wp_query in woocommerce
- WordPress Apply filter in plugin causes 500 internal error
- Meta query for comparing two dates
- Replacing global wp_query
- Error in pdf generating plugin using FPDF
- Return multiple values in a shortcode attribute
- woocommerce search by sku and title ajax
- Loop returns the current page’s permalink and guid instead of the post in the loop
- Add user meta after a user has registered and logged In [closed]
- How to get CPT category checkbox list and show post of selected(multiply) checkboxes via ajax?
- BuddyPress activity on edit post for a CPT
- How to display a number of posts based on a Advanced Custom Field (ACF)
- Delete data from custom table when deleting a post
- How can i listing current category and Featured Category post list?
- Pagination not working
- How to find the WordPress Nextgen galleries which are not used in WordPress posts?
- Adding CASE in WP_Query
- Searching a tab/space delimited text file based upon form criteria and returning a ‘record’ into a word press results page
- Woo-commerce Update price as a Bulk from My offline software export
- How to search post titles with whole words only, but not the exact word only?
- Trying to get property ‘ID’ of non-object in /wp-includes/class-wp-query.php on line 4044
- Use get_pages() before another plugin modifies it
- how to display recent post by category on home page
- How to Join wp_posts & wp_postmeta table using custom query
- What database state changes happen after a post is manually “updated” with no changes?
- any word search WordPress
- Warning: call_user_func_array() problem can anyone help with it?
- Fatal error: Uncaught Error: Cannot use object of type WP_Error as array in /../plugins/rm-payment.php
- adding dynamic/multiple slug values in ‘option_none_value’
- custom post type get_posts() function not work
- How to get a specific string from a url
- WooCommerce Product Table – filter query on attributes
- How to pass multiple custom fields as shortcode’s parameters
- Checkbox field that add a subscription product and change prices of other products in checkout and cart page
- Is it possible to custom set query for a WordPress REST API response?
- Only return taxonomies that are linked to a category & product
- How to add specific posts to specific pages in WordPress?
- How to use information from the database in the front-end?
- User Following System
- How to fix slow comment query?
- ACF Query result in a new td (echo)
- Multiple Meta key in search
- wp_schedule_event function reference
- History of page, interval of years
- How to insert variable which contain array value in wp_options table?
- how to repeat taxonomy in different places on wordpress
- Trending Tags based on post views
- Shortcode in a blog post, footer and related products stop working
- Plugin does not create a custom table upon activation
- How to delete only user meta value (not key) from usermeta table in wordpress?
- How can i see/log all requests coming from a registration form (not from the UI)?
- w3 total cache and post__not_in
- Show all posts of all categories but excluding a category on custom blog page with pagination of my theme
- Action hook “wp_insert_post” works but not for last imported post
- WP_Query Date Filtering Inclusive Being Ignored
- Second foreach loop breaking (Posts2Posts)
- get post excerpt by query
- Advanced Custom Fields (ACF) Plugin – Random Image in Sidebar
- Ger posts from similar tags and categories
- wp_query for more fields plugin
- WordPress filter function using query modifications
- wpdb get_var is not returning any result (verified mysql query returns only one value)
- WordPress Meta Query: Relation is not working correctly
- WordPress ultra slow if I click on posts?
- Insert data in custom table during new post creation
- single.php fires more than once after clicking on any post to view with different post id each time
- WordPress plugin not eching popular posts
- Making a Custom Post Type Publish Loop
- Include subtitle display to slideshow
- Checking url from plugin [duplicate]
- Browser Cache causes ‘Orderby=rand’ to return the same posts
- ‘Active lotteries’ only custom query for woocommerce lottery plugin and elementor
- I want to display data last 7 days with date wise in chartjs?
- Order custom post type by posts with most likes first
- Accessing Correct Database to Create REST API Endpoint
- What is the easiest way to create a custom field archive?
- WP_Query does not return the result even if the data is present in the database
- Show the author only own types of publications. (JetEngine, Elementor)
- How to filter posts with a wp query by a custom dropdown type field with the magic fields plugin
- Query Custom Post Types on Available Dates