Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

So I am making a news website about the future, 2112 to be specific (hello, critics). I wanted to display a post's date to be from 2112. But when I try to do this from the admin panel, it 'schedules' the post. I really want to publish the post in this century. Any help, people?

share|improve this question
2  
Just to be clear, do you want a publish date of 2112 or do you want a post that claims it was published in 2112? Or do you want a future published post to show regardless? If you can make the distinction between public facing what it says vs internal details too, e.g. a post that's published in 2012, but says 2112 on the frontend... –  Tom J Nowell Sep 4 '12 at 22:49
    
Hi, just want to show the date on the public facing post to be 2112. I think it would help if the internal post dates are actually not changed at all. –  capex Sep 4 '12 at 22:53
    
possible duplicate of How to set a custom post type to have viewable future posts –  kaiser Sep 5 '12 at 9:47
add comment

4 Answers

up vote 3 down vote accepted

I had the same issue as you when I was dealing with events and wanted to show future events.

Here is what I coded:

add_action( 'init', 'change_future_posts_to_post_now' );
function change_future_posts_to_post_now() {
    remove_action("future_post", '_future_post_hook');
    add_action("future_post", 'publish_future_posts_now', 2, 10);
}

function publish_future_posts_now($depreciated, $post) {
    wp_publish_post($post);
}


add_filter('posts_where', 'show_future_posts_where', 2, 10);
function show_future_posts_where($where, $that) {
    global $wpdb;
    if("post" == $that->query_vars['post_type'] && is_archive())
        $where = str_replace( "{$wpdb->posts}.post_status = 'publish'", "{$wpdb->posts}.post_status = 'publish' OR {$wpdb->posts}.post_status = 'future'", $where);
    return $where;
}

Please see here How to set a custom post type to have viewable future posts where I had the same question when dealing with a CPT.

share|improve this answer
    
+1 BUT the $where should be $wpdb->prepare();d. –  kaiser Sep 5 '12 at 9:48
    
Feel free to edit code to improve ;) –  Brady Sep 5 '12 at 9:51
add comment

This might work:

$date = get_the_date();
$date_unix = strtotime($date);
// now lets add 100 years
$date_unix += (100*365*24*60*60);
$echo date('U',$date_unix);

The main issue this faces is that there may be a cut off/rollover around 2030~ depending on your system. In those cases, print out the current date, but without the year, then manually print the year afterwards, e.g.:

echo get_the_date('l, F j,').' 2112';

The issue here being that the 1st january 2013 will become the 1st January 2112 not 2113

share|improve this answer
add comment

What about making a taxonomy for 'future year' and then assign it as 2112 in your posts?

You could go further and make a secondary date custom value for all your posts and sort by that instead of the real date.

(Also? Rush!)

share|improve this answer
    
I like the sound of secondary date custom value. Any pointers to how? –  capex Sep 4 '12 at 23:14
    
@brady -- Just grabbing this: codex.wordpress.org/Custom_Fields -- Then you make a custom field for 'futuredate' and ... something like this: <?php $posts = query_posts($query_string. '&orderby=meta_value&meta_key=futuredate&order=DESC' ); } ?> (Clearly I have no idea how to newline) –  Ipstenu Sep 14 '12 at 20:33
add comment

You could use a simple custom field for adding future post dates.

If you don't see custom fields in the post/page editor, then click on screen options(top right area of editor screen) and make sure "custom fields" is checked.

Now, looking at the custom fields box in the post/page editor, click on "Enter new". For the "Name" text field, enter a descriptive name for your custom field such as "futureDate": in the "Value" text field enter the date you would like to have displayed.

Finally, you will need some code in your template file to display what you have stored in the custom field. It could look like this:

 if(get_post_meta($post->ID, 'futureDate', true))
 {
    echo get_post_meta($post->ID, 'futureDate', true); 
 }

Using this method you could also order your posts by this custom field value with a query such as this(not tested):

query_posts( array('meta_key'=>'futureDate', 'orderby'=>'meta_value') );
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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