There are two solutions for that:
1. Make sure that all posts have that field set.
You can do this easily – just use save_post
hook and set it to default value. (You should also add default values for already existing posts that don’t have that field set.)
2. Use a little bit modified query
$faqArgs = array(
'post_type' => 'faq',
'meta_key' => 'faq-order',
'order' => 'ASC',
'orderby' => 'meta_value_num',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'faq-order',
'value' => 'bug #23268',
'compare' => 'NOT EXISTS'
)
)
);
$faq = new WP_Query($faqArgs);
Related Posts:
- Loop through multiple custom fields with increasing number
- WP_Query vs get_posts
- Usage of the new “posts_clauses” filter in WordPress 3.1?
- WP_Query: query posts by ids from array?
- How to get order of posts?
- Order posts by ID in the given order
- Custom WP_Query order by post_meta and (author) user_meta
- Sorting posts by custom date fields (non standard date format)
- pre_get_posts with get_posts
- How to order posts tag by tag?
- Query Custom Meta Value with Increment
- Identify which loop you are hooking into; primary or secondary?
- WP_Query ordered by custom field that is a date string?
- Group posts by custom field
- Order posts by tags count?
- Order posts by date and then by custom field
- Revolution Slider Orderby Two Custom Fields
- Transient pagination not working properly
- meta_query on a date range using an array of values
- Splitting the main query in multiple loops with query_posts and/or pre_get_posts?
- Show all parents and children in custom post type in right order
- Custom Post order for homepage
- WP_Query Order by Specific Post ID First
- Order Posts by meta value AND published date
- Undefined WP_Query::has_posts()?
- Create ONE callback for all page templates, post filter queries + paginated pages, triggering pagination via AJAX
- if/else on custom query gives 200 OK when condition not met?
- Upcoming Event: How do I sort database by custom date field, but ignore past dates?
- Add quicklink to in the Admin posts page where I can query by a meta_key
- How to Filter Posts by Custom Fields?
- How to orderby multiple meta fields if some fields are empty
- Orderby is working with one query but not with other
- Weird orderby => post__in issue
- Get a list of posts with associated meta_value
- Order by summing multiple values
- Understanding the orderby in WP_Query?
- How to order posts by title after they have already been sorted by category
- Check if loop has any categories?
- meta_value_num not ordering all items
- How to get list of posts from permalinks?
- Is_single() conditional tag returns null in query
- Transient api Caches confused
- Include current post into loop
- WP Query – order posts by meta field first and then order the rest
- Conditional operator OR not working with custom fields
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- Should I reset $wp_query?
- WP ForLoop to compare meta information of posts to determine what post to display
- How to filter query loop block with a search string from the query parameters
- Query only displays one page_id
- Filtering by multiple conditions in the loop
- WP_User_Query orderby meta_val_num
- WP_Query custom order and pagination
- Sorting posts by Multiple custom fields in defined order
- I am officially missing something about transient posts
- WP_Query orderby random do not repeat infinite scroll – one loop
- Query multiple post types, but different order for each
- display ACF repater field in archive page
- Meta query orderby meta_value_num sorting by role first
- Order posts by tags count?
- Query against multiple locations within single custom post type post
- Problem with my loops
- How to get_comments() ordered by date and parent?
- Order 2 meta_queries differently in WP_Query?
- WP_Query & Duplicate entries
- WP Query. Ordering posts by another post types meta
- Query by meta value (add a dropdown of all values)
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- how to show more than 1 post into three columns query
- Display three sequential posts on each page load, without repeating previous
- orderby in WP_QUERY – Use the order from the Dashboard
- Ordering Posts by parent category, name ascending
- WP_Query secondary query failing
- Order Custom Field by Price
- WP_Query a custom field value bringing back 0 results
- Custom search (wp query by custom fields)
- How do I display posts with specific value in a custom field into my loop?
- query_posts with sorting on a custom datestamp
- Order by multiple meta keys on wordpress
- meta_query dates from an array
- Main loop querying current template’s info only in custom category archive pages, not my posts
- Get posts that were most recently tagged
- Woocommerce set loop_shop_columns to be 3 in the main shop page loop only and 4 otherwise
- WP_Query sort by ACF date field (newest first) with blank dates first
- How can I use order_by to order by two meta_keys without excluding posts that don’t have those keys initialized?
- Loop within a loop?
- Highlighting Sub topic in a post?
- how to retrieve specific product attribute value in an sql query?
- Setting get_queried_object
- Sort query by author: 1 author, then others
- Check return value of get_posts
- Get a list of posts by specific category
- WP_Query – Adding “offset” posts to the end of the loop
- Shortcode for custom query not returning results when attributes are added
- wp_query is showing posts from other categories
- ACF: How can I publish values of ACF fields in a loop while using wp_query?
- WP_Query random ordering not working since 5.4
- Paging works correctly on local version, but not live?
- Create global array to compare inside a query
- Custom post types loop on a page template