Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6695329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:12:33+00:00 2026-05-26T06:12:33+00:00

The following code shows the posts made the last 30 days. Every post I

  • 0

The following code shows the posts made the last 30 days.
Every post I have it has a meta_key named expiring with a meta_value of 2011-10-22 for example.

In my case, I want to remove the post_date and find what posts are near to be expired. For example, today we have 2011-10-18 and I want to show all the posts that have dates from today (18) until 2011-10-21. That means 3 days after today.

Tomorrow 2011-10-19 it must show posts that may also expire in 2011-10-22.

This is how I get the value of the meta_key get_post_meta($post->ID, 'expiring', true);

This is the function I tried to edit.

<?php
function filter_where($where = '') {
    //posts in the last 30 days
    $where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
    return $where;
}
add_filter('posts_where', 'filter_where');

query_posts('post_type=post&posts_per_page=10&order=DESC');

while (have_posts()): the_post(); ?>

<li><?php the_title(); ?></li>

<?php
endwhile;
wp_reset_query();
?>

Thank you for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:12:33+00:00Added an answer on May 26, 2026 at 6:12 am

    I don’t know if I understand the problem properly, but it seems you want to have this in your function:

    $where .= " AND expire_date < '" . date('Y-m-d', strtotime('+3 days')) . "'";
    

    Sort on expire_date, rather than post date, and take everything where the expire date is not later than 3 days in the future.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code that shows 5 posts each being the latest from
I have the following code that shows either a bug or a misunderstanding on
I have an archive page that shows custom posts, each of which has a
I have the following code in my controller after the user posts the form
I have following code $.ajax({ type: 'POST', url: 'index.jsp', data: 'id=111', dataType: 'jsonp', success:
The following code shows a button that allows you to select a file (should
Consider the following code which shows compile time error : #include <stdio.h> int main(int
The following piece of code shows an Insert table dialog: Dialog d = WordApp.Dialogs[WdWordDialog.wdDialogTableInsertTable];
In the following code, the first log statement shows a decimal as expected, but
i have following code to show div on page <div id=all_users> <div id=user11 userid=11

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.