WordPress.org

Ready to get started?Download WordPress

Forums

Can't preview posts in Wp 3.2.1 (6 posts)

  1. a_crezo
    Member
    Posted 2 years ago #

    Attempting to preview a post (published, public) allows preview (unnecessary, since it is published and public and easily accessible from the front end.)

    Attempting to preview a post (scheduled, public) returns a 404 Error.

    Attempting to preview a post (draft, public) returns a 404 Error.

    Attempting to preview/view a post (published, private) returns a 404 Error.

    Attempting to preview a post authored by another user (author access v. my admin access) returns "You do not have permission to preview drafts." <--- THIS IS A PROBLEM. Has anyone found a fix for this yet?

  2. MrsCassandra
    Member
    Posted 2 years ago #

    Hi,

    I had a very similar problem and finally fixed it only restoring/repairing all permissions of all folders in the website.

    Fortunately my hosting provider offers a feature that does exactly this task automatically.

    Have a look if your provider has a similar feature or check permissions.

  3. FlashUK
    Member
    Posted 2 years ago #

    I have the same problem but have not found a solution yet.

    The same problem still occurs on my localhost. The Super Admin can preview posts but other users, even one's with Editor permission, still cannot preview posts.

  4. FlashUK
    Member
    Posted 2 years ago #

    Tracked it down to the following code in my theme:

    add_filter( 'pre_get_posts', 'my_get_posts' );
    function my_get_posts($query) {
    
        // Alters the main query to include different post-types by default everywhere
        // Useful when you want to mash up everything into the same feed
    	if ( !is_admin() && false == $query->query_vars['suppress_filters'] ) {
            // Add your different post-types below ie. reviews, previews etc.
            $query->set('post_type', array(
                'post',
                'review'
            ));
        }
    
    	return $query;
    }

    Looking at how to fix it.

  5. FlashUK
    Member
    Posted 2 years ago #

    Fixed it. Originally I took my example from http://justintadlock.com/archives/2010/02/02/showing-custom-post-types-on-your-home-blog-page but didn't add any filtering for the category or the home page.

    Here is the updated code:

    add_filter( 'pre_get_posts', 'my_get_posts' );
    function my_get_posts($query) {
    
        // Alters the main query to include different post-types by default everywhere
        // Useful when you want to mash up everything into the same feed
    	if ( !is_admin() && false == $query->query_vars['suppress_filters'] ) {
            if (is_category() OR is_home()) {
                // Add your different post-types below ie. reviews, previews etc.
                $query->set('post_type', array( 'post', 'review' ) );
            }
        }
    
    	return $query;
    }
  6. jcdesign
    Member
    Posted 2 years ago #

    @FlashUK,

    Thank you for documenting your fix. I'm using custom post types extensively on a site, and we built this function right into the theme. Adding that filter for is_category() || is_home() did the trick. Now I can preview posts!

    (Using WordPress 3.3.1)

Topic Closed

This topic has been closed to new replies.

About this Topic