WordPress.org

Ready to get started?Download WordPress

Forums

"Error 404" on future posts (but not in firefox) (5 posts)

  1. pdlr
    Member
    Posted 6 years ago #

    Hello, I am using future dates on posts as a calender. I've got everything up and running except that future posts show up as "error 404" on safari and internet explorer.

    i am actually talking about single.php not any page showing future posts as an archive-type query.

    i am completely dumbfound as to how to approach this one.

    thanks for any help.

  2. pdlr
    Member
    Posted 6 years ago #

    Ok, so far I have found out that future posts can only be seen by logged in users.

    the weird thing is that i can see a category page (archive.php) with future posts (including content) on a browser i'm not logged in on.

    but i can not see that future content as single.php. yet the code on these two templates is almost identical.this is an authentication issue, i think.i have searched for an answer, but to no avail.

    any suggestions from anyone?

  3. pdlr
    Member
    Posted 6 years ago #

    the reason i could not see the post in the other two browsers was because i was not logged in on them. since, i have found the following code in the $get_posts() function.

    if (mysql2date('U', $this->posts[0]->post_date_gmt) > mysql2date('U', $now)) { //it's future dated
    					$this->is_preview = true;
    					if (!current_user_can('edit_post', $this->posts[0]->ID)) {
    						$this->posts = array ( );
    					}

    I think this is the line that makes future posts visible/invisible. can anyone help edit this?

  4. pdlr
    Member
    Posted 6 years ago #

    the whole piece of code looks like this:

    // Check post status to determine if post should be displayed.
    		if ( !empty($this->posts) && $this->is_single ) {
    			$status = get_post_status($this->posts[0]);
    			if ( ('publish' != $status) && ('static' != $status) ) {
    				if ( ! (isset($user_ID) && ('' != intval($user_ID))) ) {
    					// User must be logged in to view unpublished posts.
    					$this->posts = array();
    				} else {
    					if ('draft' == $status) {
    						// User must have edit permissions on the draft to preview.
    						if (! current_user_can('edit_post', $this->posts[0]->ID)) {
    							$this->posts = array();
    						} else {
    							$this->is_preview = true;
    							$this->posts[0]->post_date = current_time('mysql');
    						}
    					} else {
    						if (! current_user_can('read_post', $this->posts[0]->ID))
    							$this->posts = array();
    					}
    				}
    			} else {
    				if (mysql2date('U', $this->posts[0]->post_date_gmt) > mysql2date('U', $now)) { //it's future dated
    					$this->is_preview = true;
    					if (!current_user_can('edit_post', $this->posts[0]->ID)) {
    						$this->posts = array ( );
    					}
    				}
    			}
    		}

    the first comment line says "Check post status to determine if post should be displayed." so i think this is it but i am not a programmer. any help?

  5. superann
    Member
    Posted 5 years ago #

    Well it's a hack but if you change the line:
    if ('publish' != $status) {

    To:
    if ( ('publish' != $status) && ('future' != $status)) {

    The single post will be displayed once again...

Topic Closed

This topic has been closed to new replies.

About this Topic