I was afraid you wanted that one. You can’t really do that. Follow the link for some workarounds. You could also set a variable or a constant in functions.php
, or create a theme option for this. Then use that in your function.
function smbd_cats_by_days ($where="") {
// global $days_limit; // if a variable
// $days_limit = DAYS_LIMIT; // if a constant
// $days_limit = get_option('days_limit',100);
// you have to uncomment one of the above,
// depending on your choice of mechanisms
$where .= " AND post_date < '" . date('y-m-d', strtotime("-{$days_limit} days")) . "'";
return $where;
}
add_filter('posts_where', 'smbd_cats_by_days');
Related Posts:
- How to limit search to first letter of title?
- WordPress Search Filter Only for Page with Child of Child of Child of Child of Child
- Problem with ‘post__not_in’
- Sort X categories by last update and show image
- using post__in allow duplicate post id
- Counter code for paginated category pages in wordpress
- pagination in author.php template returns 404 error
- How to modify the query to exclude posts by slug?
- How to implement time filter to show random post 1 month for one category and 3 months for other categories
- Querying posts with meta value that begins with a certain pattern
- Adding Variables to post query
- Tricky WP Query
- query_posts() ALWAYS displays something?
- Using ajax with paging and a custom sub-query
- Get Posts updated or published within the last x hours
- define orderby URL with meta_key=post_views_count
- How to remove a plugin filter’s priority on specific loops (custom queries)?
- Each post is showing twice in my custom query…?
- Filter post query to only show direct children of category
- Exclude posts by post meta value
- Currently using a query_posts() in my theme – want to use a request filter in stead
- Can I use WP_Query one time and then filter the results multiple times
- Different layout based on post amount?
- How to solve this without flushing the rewrite rules for each post query the visitor triggers?
- How to check a list or feed of all posts under a category and tag?
- Best Query for blog posts
- Pre-existing arguments when using queries
- Adding Category Argument into an Array for WordPress Query
- When should you use WP_Query vs query_posts() vs get_posts()?
- How to Get All Posts with any post status?
- posts_per_page no limit
- How can i get count from query post
- query_post by title?
- Why query_posts() isn’t marked as deprecated?
- Alternative to query_posts for main loop? [duplicate]
- Wp get all the sub pages of the parent using wp query
- how to query posts by category and tag?
- Using WP_Query to Query Multiple Categories with Limited Posts Per Category?
- Get the ID of the latest post
- How to query for most viewed posts and show top 5
- Order by meta value or date?
- How do I query by post format in WordPress 3.1
- Display posts of the last 7 days
- How to modify posts_where filter only for the search query
- Is there a way to exclude the content from the post variable to save on RAM usage?
- Filtering posts by post meta data
- get_next_posts_link() stops displaying at page 4
- WP-Snap too slow (caused by WP_Query?)
- Adding an orderby filter, casting postmeta with multiple keys
- Multiple post queries -category,posts per page,orderby
- Displaying posts by year
- Query posts based on parents attribute
- Is that the query_posts() the real criminal here?
- Creating pages and getting their values from the database table
- How to optimize ‘select found_rows()’ query? Several ‘high load average’ alerts daily
- Custom MySQL query to list post
- How to limit post query to only return a total count of items with certain post statuses?
- How to can I search range of products using between
- query multiple posts by id using a string parameter, not array()
- orderby not working for query_posts using array of IDs
- Query specific posts from parent by slug rather ID
- How to limit the number of posts on the home page?
- How to grab data (titles, thumbnails and custom fields) from multiple posts to populate a new array efficiently?
- Collect posts from last 48 hours
- query_posts – slightly more advanced query
- Query posts in a category and include only one post per author?
- query_posts and sub pages?
- How to refine WP-Query with further criteria
- Query Posts Creates 404 Error
- The_content display a different content from a previous loop
- How to go to tag archives using a form
- Run second query on page based on author of the first query
- WordPress loop problem: Multiple loops, index.php and is_paged causing duplicate posts on next page
- Query Posts (post meta)
- Why doesn’t this page query work?
- Including post data in a sidebar occurring outside of and before the Loop
- Multiple loops with / without sticky posts and different post limits
- get all posts with certain meta data
- Does wp_query and query_posts affect website performance? [duplicate]
- Filter posts by multiple checkbox categories
- prevent display duplicate titles on main page
- Achieving pagination with `query_posts`
- query_posts works while get_posts doesn’t
- Resetting a Query using wp_reset_query() or wp_reset_postdata() does not work
- Sort posts with multiple meta_keys
- Lots of SQL queries
- How to get custom post type posts with certain multiple tags names and category id?
- Create “archives by year and week” by category template
- How do I find the first item in the post array?
- Limiting the amount of posts this displays
- Trying to set up a range filter for related custom post types
- ‘Active lotteries’ only custom query for woocommerce lottery plugin and elementor
- Woocommerce set loop_shop_columns to be 3 in the main shop page loop only and 4 otherwise
- Query Multiple Filters, one with Meta
- Sort Posts Alphabetically Based on Specific Category (Divi)
- Custom Filtering date with newsletter
- How to use parse_query() to add an additional filter based on content to page search?
- Modify WordPress Search
- Display featured posts first, then display all others within a specific category in WordPress
- How to get posts in the exact quantity in default WP query via query_posts?