In order to query posts with a date_query
, you can pass the argument of column post_date_gmt
which is the date the post was published, and then pass the argument of before/after
and a string to represent your request. So for published posts from now until 90 days ago, you would put this in your WP_Query
args:
'date_query' => array(
array(
'column' => 'post_date_gmt',
'after' => '90 days ago',
)
)
This says get me all posts from 90 days ago and AFTER, which would stop at present time.
You could pass the string 3 months ago
, 1 year ago
, etc. It basically takes on the same behavior of strtotime()
.
Related Posts:
- Query posts only with featured image
- get_query_var function not working at all
- get_query_var( ‘paged’ ) not working outside of homepage
- Order by Category and Post in WP custom Query
- get custom post type by tag
- Does tax_query really beats meta_query in all situations?
- Execute a large WP_Query with many “AND” Meta_Queries?
- Using WP_Query To Get Posts Randomly From today
- How to know which one is the main query?
- WP_Query can’t exclude more than 1 author?
- How to order posts by custom WP role?
- Generate a tabbed submenu — from taxonomy term or submenu item — with sample content
- posts2posts query using connected_items array issue [closed]
- WP Query and order by particular specified IDs
- Get the post permalink within the loop but without additional DB query
- Display revision if post status is pending
- Meta query field order together with post_date order causes posts without the meta field to be unordered
- How To Remove/hide some specific categories from two different categories widget from sidebar
- WP Query search for attachments and their exact title
- How to add another parameters to WP_Query?
- Undefined property: WP_Query::$post
- Excluding Sticky Posts from The Loop and from WP_Query() in WordPress?
- How to display posts month by month?
- Query different number of posts with different formats in one go
- Extending woocommerce admin product search
- Pagination is broken and I need help fixing it
- How to display a posts 1 year ago with custom WP_Query loop?
- Check on which page specific result exist
- WC displaying products from category
- Loop returning only 1 result
- Fetch posts that match term slug first two letters (wp query)
- How can I use $wp_query->tax_query as tax_query parameter for a new WP_Query instatiation?
- How does one perform a sub query with different post types
- Query with search and subscribers only output
- Query Page Content From Theme Options?
- Better wordpress attachment query than this
- How to number the posts (ie #1, #2, #3) in a wp_query?
- Does wp track views for posts?
- Pagination only won’t work in author template
- How can I check for a thumbnail in WordPress?
- WP_query exclude posts of a format
- Can’t sort custom post type by random
- WP_Query gives me different results depending on the category order
- Make a SQL query with wpdb in WordPress
- post_type argument not working correctly with WP_Query
- Use WP_Query or query_posts() or get_posts() for optimizing a site?
- how to get wordpress user id when user register
- WP query is calling get_userdata and throws error [closed]
- How to set up hierarchical relationships without using plugins / meta query
- 2 column recent post query not respecting float right [closed]
- Meta query compare for ID’s greater than specific ID
- WP_Query meta value order is not working
- WP_Query->request has a limit
- Add parameter to first post only
- using nav menu id’s
- Ignore image urls in wp_query search
- Single post – display list of all posts + specific post
- Performance concerns: index.php vs taxonomy-$taxonomy.php
- Why does apply_filters behave different inside and outside a loop?
- Modify output of custom loop using WP_query
- What’s wrong with this wpdb query?
- The Events Calendar, wp_query returning event date not published date
- meta_query where the meta value is not the post title
- Elementor posts custom query based on tag [closed]
- SQL query injection with fifu image
- How do I use multiple similar queries with WP_Query on the same page?
- WP_Query order by multiple meta keys & fields
- WPQuery Date and ACF
- Is WP Query skipping to check next post when an argument is not met?
- 3 posts from each existing category on one page
- meta_query is overriding default search
- Custom Woocommerce Product Query
- How can I write a WP_Query that is this specific?
- Pagination inside the blog page not working
- How to query most recent post for each author?
- Custom Query Pagination not working on static front page
- Post Template Query with WP_Query?
- How to create URL parameters to run custom queries?
- Adding additional taxonomies to wordpress taxonomy page
- why doesn’t this pre_get_posts code work?
- Query Top Set Custom Taxonomy In Given Timeperiod
- Custom taxonomy and query multi conditions
- Best way to Order Post in Home without a plugin
- WP_query issue with no posts
- How to get query results for the next page
- wp_query in form method of widget breaks customizer
- Featured image not showing on page
- Add filter to Orderby Parameter using Array
- Iterate through ID’s in loop
- Multiple loop for “featured” items returns wrong posts
- Get WP_Query query after execution?
- Query string form $_GET[‘value’] is not working as meta value in wp_query
- query_posts problem – need help
- 294 Queries on Mainpage of WordPress
- Pagination on custom post type not working
- taxonomy-{term}.php terms pagination returning 404 after a certain page
- Using WP Query, I want to include all posts in category 1 as long as they are not also in category 2
- Prevent URL Parameter Affecting other WP Query
- Sort by multiple columns using get_posts
- WP_Query filter Posts by timestamp event (range start and end) and by month (next 12 month)