[resolved] HOWTO: Show a post for only 5 days (6 posts)

  1. shaunandrews
    Posted 9 years ago #

    My index page has two loops. The first loop only shows one post from one category, sort of a sticky post implementation. My question is how can I have this post show for only a certain amout of time, say 5 days.

    Here's my query:


    So basically I want to use some logic to only show the post if its date falls within the last 5 days.

  2. shaunandrews
    Posted 9 years ago #

    no one?

  3. shakeb
    Posted 9 years ago #

    I am relatively new to WordPress but If I were you I would think that cronjob/crontab is one way to do this.
    There is a crontab plugin http://www.skippy.net/blog/category/wordpress/plugins/wp-cron/
    Also here is a link to timestamp plugin

    get the timestamp check it using crontab and if it matches your criteria delete/hide that post. (There could be a plugin for hiding posts )
    If you know PHP you would probably know what I am getting at.

    I haven't checked WP APIs yet and have no idea how it is coded. A developer could probably hint and suggest what to do.

    P.S. I could be totally wrong though :(


  4. shaunandrews
    Posted 9 years ago #

    I got it all figured out. I ended up using some PHP to compare the current date to the date of the post using Unix time. Worked like a charm.

    I'll be posting an in-depth tutorial shortly at http://www.shaunandrews.com/

  5. yosemite
    Posted 9 years ago #

    Cool, and kudos for thinking of others (tutorial)!

  6. shaunandrews
    Posted 9 years ago #

    As promised here's a tutorial on how to do sticky posts that dissapear after a few days:

    WordPress Sticky Posts

Topic Closed

This topic has been closed to new replies.

About this Topic