So the question seem unclear, i rewrite it to hope for the best and get some great ideas.

I write a WordPress Sticky post (always first on top). In that post text there is something written like : Act fast, enroll in the next class. next date : sept 10 2012.

But as time past, date changes, and to keep that post current date must be change. So where I can put a list of date, and automaticly change the post date (text) according to the next date base on today date...

what plugin of php code can do that... i think shortcode can do that, but what your way to fix that ?

-- example listing of date :

  • sept 10 2012
  • sept 30 2012
  • oct 5 2012
  • oct 22 2012
  • ....

based on that example, let's say today it's oct 1st, so i like the post to read : Act fast, enroll in the next class. next date : oct 5 2012. So like that the date list ignore the past date (to late the course is done) and show the next date based on today date, and let people know... hurry, it's soon or never. I know there will be other date, but the customer dont have to know that !

Editors note: For clarification, here's a short explanation what the OP is asking for.

  • A post has multiple "dates".
  • Each date represents a change to the post content.
  • When a date passes, the template should autom. recognize that and switch the content.

Disclaimer: This is what I've understood.

  • Your question is completely unclear. Please rework it. You should also try to write in complete sentences using upper-/lowercase letters and proper punctuation to make it easier to read and understand.
    – kaiser
    Commented Sep 29, 2012 at 13:23
  • your right, usually, people here are great help, and to get some help i should ask in a way to get help... I will redo that. And BTW, sorry for the poor English, i am french !
    – menardmam
    Commented Sep 29, 2012 at 17:25
  • n/p. English isn't my native tongue either.
    – kaiser
    Commented Sep 29, 2012 at 17:25
  • At this point, it's like a new question that start with 2 vote down and 3 vote to close.... can you remove that ? it's sad ! :-(
    – menardmam
    Commented Sep 29, 2012 at 17:42
  • I removed the downvote, but close votes can't get removed. You can vote to reopen, once its closed. The problem still is, that your English is very hard to understand.
    – kaiser
    Commented Sep 29, 2012 at 18:00

1 Answer 1


Here's summed up what you need to do:

  • Get a meta box library.
  • Add custom fields with dates
  • Attach a filter callback action to the_content filter
  • Get the current date, check your custom fields, append date in content.

So here's the filter callback, that lets you append your "next date":

function wpse66615_date_to_content( $content )
    $dates[] = get_meta_custom( get_the_ID(), 'THE_KEY/NAME_YOU_ADDED', true );
    $dates[] = get_meta_custom( get_the_ID(), 'ANOTHER_KEY/NAME_YOU_ADDED', true );
    // $date_c = ...

    // We need the current time to compare (UNIX timestamp)
    $today = current_time( 'timestamp' );

    foreach ( $dates as $key => $date )
        // Now get rid of all dates that already passed
        if ( $today > strtotime( $date ) )
            unset( $dates[ $key ] );

    // We really ran out of dates...
    empty( $dates ) AND $dates[] = 'There is really no date left';

    // Then take the first array item from our left dates
    $next_date = array_shift( $dates );

    // Then we append it to the content
    return $content."<br /><strong>Next date:</strong> ".$next_date;
add_filter( 'the_content', 'wpse66615_date_to_content' );

When you now call the_content(); or apply_filters( 'the_content', get_the_content() );, then you'd get an output like the following:

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.

Next date: d-m-Y

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.