Never tested this ,but i believe you need to add WHERE clause to your query with time difference
like so :
$timediff .= " AND post_date > '" . date('Y-m-d', strtotime('-2 days')) . "'";
you can find it also in the codex
http://codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters
If you do not want to use on query, but inside the loop, you could also do
<?php while (have_posts()) : the_post(); ?>
<?php $mylimit=15 * 86400; //days * seconds per day
$post_age = date('U') - get_post_time('U');
if ($post_age < $mylimit) { ?>
// your functions or display here
<?php } ?>
<?php endwhile; ?>
Related Posts:
- How can i get count from query post
- Using WP_Query to Query Multiple Categories with Limited Posts Per Category?
- Is there a way to exclude the content from the post variable to save on RAM usage?
- Display/query post formats
- How to query post by user role?
- Ensuring sticky posts are retrieved first (without using two queries)?
- Determine if more posts are available than was asked for in `query_posts()`?
- query_posts() in function makes global $wp_query out of sync?
- Limiting query_posts to 1, regardless of sticky post?
- WordPress Custom Query
- How should I intercept the main query and inject custom join / order by / group by criteria
- advice on creating a ‘related posts’ query like the one used on stackexchange
- Using dynamic conditions in ‘posts_where’ filter
- Help altering a query to exclude all but standard post format
- List users with the most total posts view
- How to limit search to first letter of title?
- Post Title displaying but not in the wrapped HTML I need
- get_post_meta causes database queries
- How to ensure that is_search() return false after query_posts
- Inserting Post Using wp_insert_post. How to Fill Yoast Plugin SEO Fields
- Why is that gdsr_sort=thumbs (GD start rating plugin) only works with query_posts and not with WP_Query?
- Query_posts $query_string
- How to order posts by slug using query_posts/ Wp_query
- Query 1 taxonomy term, exclude another
- Order by meta_key with two meta_queries
- Pagination on custom query
- Search stores (custom postcode field) within 5, 10, 15 miles of user inputted postcode.. Code modification
- Ordering terms before displaying posts
- What is the difference between “manage_{$post_type}_posts_columns” and “manage_edit-{$post_type}_columns”?
- Sort Posts by Multiple Meta Values [duplicate]
- Querying posts with meta value that begins with a certain pattern
- How to show only today’s post?
- use query_posts to return a post OR a page by ID
- Adding Variables to post query
- Unable To Get Published posts using query_posts
- ACF Custom Field WP_Query, but need to get all posts, if field doesn’t exist
- Read More is not working in query posts
- query_posts for child pages
- How to reverse the order of WordPress blog posts?
- How do I change the default sort order of a custom column on the posts page?
- orderby:date not working
- Placing post data (title, date, and excerpt) nested in static content
- query_posts() ALWAYS displays something?
- Trouble with get_next_post() get_previous_post() returning null
- Single meta key with multiple meta value in like comparison
- Possible to display posts containing a short code ?
- How to run a SQL Query for character in Post Titles
- Authors List page : how to exclude posts from certain category
- list child page items (1 level with meta keys)
- Query a WordPress page by its title (which has a parent page)
- Sorting a query Field by date
- Trying to package posts for republishing by partner offsite
- post_parent array doesn’t work
- number of posts per page + random + exclude categories
- How to Query Post
- query_post and wpdb returning different results
- Exclude current sticky post
- How to place an image after Nth number of posts in query_posts
- Related Posts: Notice: Undefined offset: 0
- query_posts pagination will always show identical content
- When to use WordPress loop or Foreach loop?
- Can’t get pagination to work for sticky posts only
- WordPress Custom Query to get Most Commented Posts in the Past 7 Days
- show x number of posts from y category on homepage
- How to Show Comment Count on Related Posts?
- How can I show only 5 posts from the relationship?
- Make query_post category name dynamic
- How can I list posts with different formats depending on order?
- query_posts orderby postmeta [closed]
- WordPress Query based on random taxonomy
- Displaying and Querying Posts with Featured image
- Restrict query_posts by Date?
- How to solve this without flushing the rewrite rules for each post query the visitor triggers?
- View Achive with Category Filter, but Page per post not working
- Sort post by custom field numeric value
- grab neighboring content in a query
- Notting but the latest post content keeps on being loaded
- query_posts doesnt show pages with given ID when post_type => page
- How to put posts in pages using query posts
- Query add html after set amount of posts?
- Custom loop off by one post
- Is there any way of only retrieving posts with one or more thumbs up (GD star rating plugin)?
- How to setup blog page to render blog posts minus afew categories
- How to get max value of filtered query post
- Ordering of posts, 2020 Year showing as next event when should be last
- How to put orderby on a custom field in query_posts
- wp_remote_post and form post
- Filter posts by current date ( WP Post Carousel )
- How to display most popular post by views count in WordPress?
- Sort Posts By Custom Field Date
- Custom query posts error
- wp_query by last month + sort posts
- Post Filter clearing on pagination $_post
- query multiple posts by id using a string parameter, not array()
- How to limit the number of posts on the home page?
- query_posts – slightly more advanced query
- Query posts in a category and include only one post per author?
- Query Posts Creates 404 Error
- Achieving pagination with `query_posts`
- query_posts works while get_posts doesn’t