Literally seconds after updating this post I found the solution….again, Must have looked at this previously and not entered the details correctly as I tried this one before. 🙂
add_action('pre_get_posts', 'add_special_sort', 11, 1);
function add_special_sort($query){
// Bail if not the main "hidden" query, as opposed to a 'new WP_Query()' call
if(!$query->is_main_query())
return;
$query->set('meta_query', array(
'relation' => 'OR',
array(
'key' => 'featured_listing',
'compare' => 'NOT EXISTS',
),
array(
'key' => 'featured_listing',
'compare' => 'EXISTS',
)
));
//$query->set('meta_key', NULL);
$query->set('orderby', array('meta_value_num' => 'DESC', 'date' => 'DESC'));
}
Related Posts:
- Advanced search form with filters for custom taxonomies and custom fields
- Custom Meta Boxes – Nonce Issue – Move to trash issue
- Show metabox in custom-post-template depending on taxonomy term?
- Displaying Metabox value (custom post type taxonomy)
- How can I display my custom metaboxes on a custom post template?
- need advice on how to do a lists using custom post types – taxonomy vs postmeta
- Count posts with specific term_meta
- Does WordPress limit the length of slug names for Post Meta or Terms?
- How to duplicate entire custom post type
- Metabox not show in categories custom post type cmb2
- Display different information of a custom post type
- Filter posts by tax (dropdown) and meta value
- how to show records that don’t have custom meta value
- best way to use custom taxonomy, post type and meta in a job system
- WordPress CPT Taxonomy Dashboard Search – How to include taxonomy in search?
- Custom Post Type meta data getting deleted on bulk editing taxonomies
- Should I use a custom taxonomy or custom post type for grouping a list of panels associated with a group of tests?
- Saving Child Terms on front end not setting parent
- Complex strcuture as CPT or taxonomy for use in woocommerce product variations [closed]
- WordPress custom post type
- Values inside a custom field to determine which category posts to display
- Timetable of Custom Meta Data using Custom Post Type and Custom Taxonomy
- Advanced search form with filters for custom taxonomies and custom fields
- Automatically add custom taxonomy when meta value gets to a set number or beyond
- Get post with multiple meta keys and value
- Custom Post Type Permalink / Rewrite not working immediately
- Custom Taxonomy as Dropdown in admin
- Custom Post type in separate database table for syncing
- Creating Photo Gallery System with Custom Post Type
- Custom Taxonomies Terms as Post Title for Custom Post Types upon Publishing
- WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)
- Correct way to use a form to to filter custom posts by taxonomy terms?
- Custom-Taxonomy as categories: Remove “most-used” tab?
- Custom Permalinks for Custom Post Types and Taxonomies
- how to group custom post type posts by custom taxonomy terms
- Showing current taxonomy terms
- Custom post type category, taxonomy and URL rewrite problem
- Custom Taxonomy order by Custom Field
- Custom Post Type: How to display all of same taxonomy?
- How can I include meta box content when searching?
- Show ACF field from custom taxonomy and display on the single template
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- how to interconnect custom post types?
- Display custom post type in hierarchical order with get_terms
- Am unable to reset a query properly
- Conditional Statement custom post type category
- Custom Post Types. Are there any disadvantages/advantages in using a plugin to develop them?
- Custom Post Type permalink shows wrong page: homepage/index.php
- Display Custom Toxonomy In WordPress and theme Widgets category selection dropdown list
- Two Custom Post Types Many to Many Relationship
- How do I require the specification of term in a custom post type and custom taxonomy?
- Update database from Quick Edit according to Checkbox state of Custom Post Type
- Custom Post Type Pagination Paginates Only in URL Structure
- I am trying to hide a custom post type category to logged in users with Pre_Get_Posts
- Hierarchial Custom Post Types/Taxonomies
- Only show posts with date of today or in the future (i.e don’t show past posts)?
- Check if post with same meta value exists
- Do posts, pages and / or custom post type objects have unique ID numbers or can there be multiple objects with the same IDs?
- Migrating Hierarchal Taxonomy Categories Between Post Types
- Cannot obtain custom meta information
- Exclude latest post from WP_Query taxonomy term loop
- Use different categories for a custom post
- Filter posts by specific custom category and current tag
- Empty meta-box returns publishdate if no value is set?
- Custom Post Type URL doesn’t work anymore
- using custom taxonomies with custom post types: display list of posts by ‘category’
- Custom category URL not displaying posts
- WordPress REST API V2: “{CUSTOM_POST_TYPE} matches Term ID List and Term ID Taxonomy Query, but should match only one.”
- display post count in archive page that have relation with another taxonomy term
- Use WP_query to match post types based on custom field values
- Pretty Permalinks with CTP and Taxonomies / Hierarchical
- Automatically add CPT UI categories to the menu
- Stored meta from attachment, video length?
- Custom category taxonomy – archive page not showing up
- tax_query not working?
- Previous/Next custom post links within custom taxonomy
- Custom post type: “transition_post_status” action get title and other fields
- Making permalink for custom post type/custom taxonomy. Stuck with 404 in the single post
- Pretty permalink structure with multiple (AND OR) taxonomies
- Custom Taxonomy is disabled on Edit page
- Override “Parent” input for custom taxonomy
- Problem with type plugin and custom taxonomies
- Delete custom post type metadata without deleting the post in admin area
- WordPress Custom taxonomy template
- Get link for feed of specific post type AND taxonomy
- Why is this custom post type defaulting to archive.php?
- Get single object term for custom taxonomy
- Sorting custom post types by taxonomy (So close)
- Check if taxonomy is attached to at least one post in a post-type
- Getting (Invalid) when adding custom taxonomy of custom post type link in menu [closed]
- Display custom taxonomy posts of custom post types
- Return Custom Post Type Categories
- Custom Post type as Taxonomy
- ACF Relationship: Group posts by parent category term, then child [closed]
- Get X posts with the same terms as the current post (custom post type and custom taxonomy)
- Changing to different post type maintains the redirection?
- Calling custom taxonomies
- Limit taxonomy terms added to a custom post type
- Is it possible to use a post name in a custom post slug?
- How do I add the “orange counter” next to a Custom Post Type?