You can try following code
$y = date('Y');
$m = date('m');
$d = date('d',strtotime("-7 days")); //Date you want
$args = array(
'posts_per_page' => -1,
'post_type' => 'post',
'date_query' => array(
array(
'year' => $y,
'month' => $m,
'day' => $d,
),
),
);
$posts= new WP_Query( $args ); //you will get posts which are posted on specific date
Related Posts:
- When should you use WP_Query vs query_posts() vs get_posts()?
- When to use WP_query(), query_posts() and pre_get_posts
- WP_Query vs get_posts
- Get posts by meta data OR title
- Meta Query with date and time on the same Day before given time
- How to find out what “Blog pages show at most” is set to [duplicate]
- How do you Query posts with nothing in common?
- add active class based on permalink and url
- Reset WordPress Post Query to default
- get_posts output always same post
- Use WP_Query or query_posts() or get_posts() for optimizing a site?
- complex get_posts() query to select child pages
- Posts query according to meta box date
- How to query for a page, get data, then query for child pages of that page
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- Facing problem with tax_query results
- Ordering Posts by parent category, name ascending
- When should you use WP_Query vs query_posts() vs get_posts()?
- Nested meta_query with multiple relation keys
- Get posts from Network (Multisite)
- Using OR conditions in meta_query for query_posts argument
- Sanitation needed for WP_Query or get_posts calls?
- Order posts by ID in the given order
- Use of caller_ get_ posts
- Query Multiple Post types each with own meta query
- How-to exclude terms from the main query the most performant way?
- Get posts by menu ID
- Get the number of posts from the current page results
- Is it better practice to use query_posts, WP_Query, or get_posts to create various custom loops within a Page?
- Get posts with condition on comment meta value
- What should I use, get_posts or wp_query for less CPU load?
- How to get post from all Blog Multisite to the Main Site?
- how to display active, upcoming and past event with featured listing with pagination
- Multiple search queries on one page
- How do you query wordpress posts using a math formula between multiple meta field values?
- How add a custom posttype name using ACF field to a query post array
- Page navigation doesn’t show when query category
- 2 loops on page – one with orderby rand second orderby date
- WP_Query, tax_query and term_meta: How to?
- Custom category search box for WordPress
- get_posts – get all posts by array of author
- Query with a meta value inside a given range
- WP Pagination on Posts Search Results Page resulting from AJAX WP Query
- get_posts() not working with multiple statuses
- Five posts from a category in footer
- Return only post(s) which have post_excerpt
- How to display multiple custom fields with the same meta_key in an ascending order?
- How to display an other custom post type in a different custom post type’s archive?
- WP_Query post_parent parameter always returns children of current page
- How to exclude post formats from wordpress recent posts in a tabs widget [closed]
- How to increase load time of an archive/search page (WP_Query)
- How to count posts with specific arguments
- Exclude All Posts Which Do Not Have A Tag Assigned
- Easy way to write complex queries in wordpress
- Filter post query to only show direct children of category
- Query_posts works when appending via AJAX call wp_query doesn’t?
- get_posts() and global variables
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- Posts Query | Query to only show sub categories
- Using get_posts to get posts based on a checkbox value with Advanced Custom Fields
- How do I add a relation parameter to my filter query?
- How to get posts by category and by choosing a taxonomy term?
- Get next/prev image/attachment in time with date query
- Function using get_posts() with tax_query not working when called from functions.php
- specific post is not excluded from the loop
- Search for pages with permalink
- Why doesn’t my WP Meta Query return any results?
- Paginate pages with dynamic query
- Trouble Making WP_Query paged
- Determine if ID is page or post and query the ID
- Execute PHP function inside the admin area
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- Optimising WP_Query with ACF Fields
- Why my query is not “Main_query”?
- Filter products on category AND tag
- Populate select list with meta values from all posts of a Custom Post Type
- Form checkbox value going to dynamic URL
- How do I stop the same post showing multiple times in a archive?
- Get posts that match defined arrays of tags
- get_posts return only first result
- How to get meta key list efficiently?
- how to get wp_query posts only first letter of alphabet A?
- trying to change from query_post to WP_Query
- I need query_posts() to order results first by a meta value and then by post ID
- WordPress For Loop Prints Unwanted Extra Paragraph Element
- Orderby query does not work for custom fields even with meta query
- query_posts() doesn’t seem to be called in my page
- Some doubts about how the main query and the custom query works in this custom theme?
- Fetching $_POST from Page Template into functions.php
- Use not custom fields in get_posts() meta_query?
- Mathematical operations on custom field values? (updated)
- Optimising specific Query with ACF meta objects
- get_posts works but new wp_query doesn’t
- query_posts with sorting on a custom datestamp
- Why WP_Query in functions.php is not working when get_posts works?
- Query Posts by date range with fixed beginning and end
- Query specific number of posts for each post type in specific order
- Having trouble using this post category query on multiple pages?
- get_posts shows current post, not defined posts with args
- How to retrieve _embed (etc) fields in get_posts custom query?