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()?
- When to use WP_query(), query_posts() and pre_get_posts
- Get post ids from WP_Query?
- Nested meta_query with multiple relation keys
- Some doubts about how the main query and the custom query works in this custom theme?
- Wp get all the sub pages of the parent using wp query
- How to query for most viewed posts and show top 5
- WP Query where title begins with a specific letter
- How to use the_posts_navigation for wp_query and get_posts?
- meta_query: using BETWEEN with floats and/or casting to DECIMAL
- Get posts from Network (Multisite)
- How to order by post_status?
- Using get_posts vs. WP_Query
- Delete all posts from WordPress except latest X posts
- Using OR conditions in meta_query for query_posts argument
- Query Posts in a Predefined Order
- Sanitation needed for WP_Query or get_posts calls?
- Differences Between WP_Query() and get_posts() for Querying Posts?
- Order posts by ID in the given order
- Get Recent Posts by Date in Multisite
- get_posts with multiple categories
- get_template_part in for loop
- 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 possible to select against a post’s parent’s fields with WP_Query?
- WordPress Custom Query to show posts from last x years
- Query all posts where meta value is empty
- Query Custom Meta Value with Increment
- How to know which one is the main query?
- Is it better practice to use query_posts, WP_Query, or get_posts to create various custom loops within a Page?
- Get_post() with meta_key when compare is a date
- Perform query with meta_value date
- Using is_main_query to select custom post type on certain page
- WP_Query ordered by custom field that is a date string?
- get_posts not finding argument: post_name
- get query’s query string
- How to get previous 10 days post from a specific date – WP Query
- get_the_title($postID) OR get_the_title()?
- Get posts with condition on comment meta value
- Retrieving 3 latest post from each of 5 different custom post types
- Display Posts by modifying the where clause only for my query
- Function to check if author has posted within the last x days
- How do I create my own nested meta_query using posts_where / posts_join?
- Use post__in and post__not_in together?
- How to use filter hook posts_join for querying taxonomy terms in posts_where?
- Best practice for multiple queries on page
- What should I use, get_posts or wp_query for less CPU load?
- Different Results with query(‘s=computer’) vs get_posts(‘s=computer’)?
- How to get post from all Blog Multisite to the Main Site?
- How to Get All Posts but the Private ones?
- WP Query post meta value
- Get all posts without tags
- how to display active, upcoming and past event with featured listing with pagination
- get_posts() seemingly ignoring post_type
- Can not switch the queried post in pre_get_posts hook
- How to query ‘posts_per_page’ to display a different blog posts index template?
- Count posts returned by get_posts in external PHP script
- Multiple search queries on one page
- Trying to check and see if a post has a featured image outside of the main loop
- How to show only one post for each categories of taxonomy of custom post that contains a specific custom field
- WP_query category__in not working, only pulls from first category
- Pass the same object to multiple widgets in a template with one query
- Retrieve or Query Pages by ID
- Quickest way to get last or oldest post date – WP Query
- SELECT * FROM $wpdb->posts WHERE ID > 160
- WP query exclude post within the last month / only show over 1 month old
- WordPress query for most recent posts from multiple categories
- 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
- How to implement time filter to show random post 1 month for one category and 3 months for other categories
- Too many posts cause slow load when paginating
- Adding multiple post queries with parent and children to page – Best Way
- Page navigation doesn’t show when query category
- Multiple instances of Featured Image Query
- How can I pick a single post from the latest 3?
- 2 loops on page – one with orderby rand second orderby date
- Query post with meta_query where date is not in future
- WP_Query, tax_query and term_meta: How to?
- Next/Prev posts on same page
- Get posts for last working week in WP_Query