you need to study about date query.
Anyways following should work
<?php
$args = array(
'posts_per_page' => -1,
'date_query' => array(
array(
'after' => '7 days ago'
)
)
);
$query = new WP_Query($args);
while ( $query->have_posts() ) { $query->the_post();
// Page title
the_title();
} // end while
// Restore original Post Data
wp_reset_postdata();
// Save memory
unset( $query );
;
?>
Related Posts:
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- Wp_redirect and sending variables
- How do I get posts that have a thumbnail in WP_Query?
- Multiple WP_Query loops with Pagination
- how does $wpdb differ to WP_Query?
- WP_Query – filter or directly?
- WP_Query with checkbox meta_query
- IP address character limit
- What is the most efficient way of querying posts based on visits and date for current day?
- How can I save an array from a random post sequence for later use?
- Does WordPress generate an automatic page for post formats?
- Why is WP-Query spelled like it is?
- How to add custom query filters in WP_User_Query
- How to order category.php loop by ‘meta_value’?
- Searching user meta using WP_User_Query
- Which custom query am I in and how can I access its properties & methods?
- Pagination not working Search posts
- Does using a custom query_var create a security hole?
- How to sort posts in admin by titles with dd.mm.yyyy format?
- Why I can’t get old posts instead of recent with WP_Query?
- How get posts from a subcategory of a category by name?
- Date query not inclusive despite parameter being true
- WP_Query or get_posts?
- How to display the number of articles published per user
- How do you query wordpress posts using a math formula between multiple meta field values?
- Change default ordering of taxonomy terms – pre_get_terms
- Ordering Posts Type A by Custom Fields of related Post Type B
- Query Posts depends on custom field inside repeater field using acf
- Exclude old events from WP_Query with date saved in a `meta_key`
- WP_Query arguments to fetch custom post type posts which are in certain category?
- WP_Query loop within WP_Query loop
- WP_Query returning no results
- Splice together 2 WP_Query objects
- pre_get_posts Remove tax_query Completely
- How to access a query twice in different template files?
- Counter problem, infinite loop when post_per_page equals X
- How to delete taxonomy term when a wordpress user is removed?
- Custom query based on meta key – Reduce three states to two in results?
- How to create a WordPress Post Filter that users can use to filter posts by year?
- Exclude category for main query and custom
- Complex Category selection as per user input
- How to set multiple `orderby` in query argument?
- WP_Query posts_per_page Only Bringing Back one post
- How to get all unique categories for posts in loop?
- Query that loads a custom type AND posts whose ids are not inside those custom types custom fields
- Meta_query with multiple keys and multiple values
- WordPress WP_Query make mysql time out
- Get authors by term id or slug
- How do I query for posts by partial meta key?
- Transient not behaving as expected
- New WP_Query calls Pre_get_posts filter twice
- Multisite wp_query & switch_to_blog issue
- the_post() within switch_to_blog() altering my excerpt
- No results found from a $wpdb->get_results() query when trying to join more than one meta key query
- WP_Query post_parent parameter always returns children of current page
- Query about wp_query
- empty WP_Query object on local install
- Changing the default wp_search_stopwords
- Query posts only without featured image
- Get posts from multiple tax terms
- How to use WP_Query() on single.php?
- Tax Query only returns for the first of several terms
- Can’t fetch Custom Post Type Data through Custom Query
- Loop increase in while loop not working
- Get All posts by Tag_Id not working, query seems to contain extra term_taxonomy_id
- Appending to existing WP_Query’s meta_query if exists
- How To Keep Search Title the same on paged Results
- Get next/prev image/attachment in time with date query
- Filter out a meta key in the Search results page with two CPT
- How to add a recent post function to a text widget I created for practice?
- Can I make a search query which includes a space?
- Help with if statement inside while loop
- WP_Query – display posts by custom field and order by another
- WP_Query no result if keyword contains number
- WP_QUERY order posts by two combined meta_value dates
- Order by value of Custom Field using url string
- How to set meta_query if get_post_meta returns nested array for that key? [duplicate]
- Is the ‘parse_query’ filter still valid to change filtered content on admin list view?
- I removed the “wp_rm_logs” table and am constantly getting this error
- WP_Query returns empty if meta_query has more than 7 values
- query.php – multiple is_category functions
- Custom query with post_class filter using current_post not working
- Overwriting auto-appended NOT IN query in WP_Query
- posts_per_page not returning correct number of posts
- query_posts with sorting on a custom datestamp
- Conditionals in WP_Query
- Why WP_Query in functions.php is not working when get_posts works?
- Next / previous posts link doesn’t show up with Posts 2 Posts
- Loop the posts between two dates selected using jquery datepicker
- query by meta value then date and not empty meta value
- Issue with sorting by post date and custom post type
- Is it possible to use WP Query to orderby custom meta value and custom taxonomy?
- Display all custom meta field values from the database using ACF Repeater
- Remove divs and spans from post content
- Can’t get LIKE to work with wp_query [closed]
- Get all user with both meta_value
- WordPress extremely slow when using get_posts with multiple meta_query relations
- Refresh wp_query with no changes
- SQL query into to WP query
- Search results stuck on page 1