Assuming that you’re trying to get all posts in the first half of 2022, as opposed to the first 6 days of 2022, then you need to be clearer with your before and after dates.
date_query
uses strtotime
behind the scenes, which will interpret your dates as Jan 1 to Jan 6. You need to either change the dates to the American format of YYYY-DD-MM, or be more specific by using arrays to express your dates instead.
Related Posts:
- Retrieving 3 latest post from each of 5 different custom post types
- Quickest way to get last or oldest post date – WP Query
- Stuck in Order by more then one
- Query Multiple Custom Posts by Custom Fields
- Group by custom field value (start and end times)
- Get posts by category name
- How to properly use Categories with Custom Post Types
- Query a custom taxonomy in a function to create an csv file
- Query posts based on user preferences
- Why get_posts() returns empty array while I am trying to get posts from some specific taxonomies and work properly with others?
- Get post from Category by Priority
- How can you use a page for a custom post type?
- date_query won’t accept day parameter, but will accept month and year for a custom post
- This wp_query will not return any posts and only seems to work with post_status inherit?
- Query posts by a type and another type only if post is in specific category
- shortcode for recent custom type post
- How do I correctly query posts from a post ID?
- Query all posts where a meta key does not exist
- Exclude a category from WP_Query
- Single loop for wp_query and wp_user_query
- WP_Query orderby custom field then post_date in one query
- query multiple taxonomies
- Custom Post Type, WP_Query and ‘orderby’
- Include post id[s] into WP_Query()
- Syntax to get the Nth item in a list of custom post types?
- Grab 5 latest posts from custom post type ‘announcements’
- Pagination Doesn’t Work
- Numeric pagination custom post type
- Sort the main query in subcategories/terms?
- How to show posts from multiple post types in a single loop? And display them separately on the same template
- Get post info inside modal window?
- Want to filter only parent post in admin area
- How to query custom post type by term?
- Pagination Issue: Custom Post Type In Index
- Having trouble with custom date field for CPT query (WordPress)
- Display posts if a custom field value is equal to another custom field value
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- CPT posts listed by category with custom rewrite URL, please help!
- How to use WP_Query in a CPT achive page?
- Use get_post_types to query only custom posts types
- How can i skip same post from taxonomy term?
- Using global $post; to get featured image for custom post via WP_Query
- Query custom post type by category slug
- Pagination on a custom post type loop
- WP_Query orderby modified to include custom meta changes
- Display all post titles of current post type
- Search / Filter posts on Title/Content OR Tags
- A method for ordering mixed dates in search result loop (theory only, no actual code)
- What’s the WP way to load remaining custom posts?
- Several post types on WP Query by tag and taxonomy
- Multiple (two) category postings on the same page.
- Filter Posts from the Main Query
- Pagination with custom query, custom search form, single and pages, ajax and no plugins
- Get only used meta_values
- How can I group posts by months and years?
- Display post from a date range from custom field
- Displaying a div from an assigned meta_value when on a page
- Getting a custom post’s custom field based on another custom post’s custom field select
- WP_Query not resetting after wp_reset_postdata
- Custom post type to lead to single post type instead of shortcode modal
- Filter posts of custom post type by meta key in (List All Section)
- Query Posts that have Custom Taxonomy
- Display post from custom post type
- Query Posts, order by meta value
- Display a random customposttype2 excerpt in single-custompostype1.php that shares same taxonomy
- Is there a (preferable built-in) way to check what custom queries are used in a theme?
- WP Query from two Custom Post type fields as statement
- Get_post_custom not fetching value from array wordpress
- custom post type and a “sticky” position taxonomy
- Display post count for a specific month
- Query to Exclude Child Pages from Custom Post Type Archive
- WP_query has incorrect wp_posts.post_name = ‘asc’ when I have custom post type called ‘order’
- Randomizing WordPress Custom Post Type Sorting Through Them Without Page Refresh
- Order posts alphabetically with numbers but some of the posts has numbers in the title
- How to output custom post type title on custom page with category next to it?
- How to sort by multiple values in a nested WP_Query
- SEARCH QUERIES – REVERSE OUTPUT
- Staggering featured post using ‘sticky’
- Ajax load more inside custom post type taxonomy
- Create a custom wp_query from a specific custom post type with specific taxonomy
- SQL LIKE in WP_Query
- Query breaking with ‘posts_per_page’ => -1
- WP Query with multiple post types ordered by custom meta date then published date
- CPT Efficient way to display posts from different categories with custom query
- How To Loop Through list with Custom Post Types
- Use Tags to Query Associated Multiple Posts and Get The Average Of Custom Field Values
- Custom Post Type + Category archive
- Values inside a custom field to determine which category posts to display
- one get_posts to return a number of custom posts for each meta value
- WP_Query get posts where post_name is empty
- How do I sort post listing by child post count?
- Pop up showing same content on all posts display.
- Querying meta values within an array
- Count of posts with meta_key filled in?
- Filter Custom post type by another Custom post type
- Archive page – problem with pagination
- Are custom posts included when getting a categories’ posts?
- Query order by meta value force specific tag first
- Default WordPress Query for a Specific Custom Post Type URL
- Dynamically count the number of custom post types associated to a custom taxonomy