WordPress.org

Ready to get started?Download WordPress

Forums

Post preview not working (4 posts)

  1. Inspireyourway
    Member
    Posted 1 year ago #

    I am using the latest version of wordpress, suddenly I found that the post preview is not working, whenever I am previewing the post it is redirected to my homepage with the preview url in address bar,
    for ex: When I am clicking preview, a new tab is opening and I can see the page is my homepage not the post preview page,
    the url is http://www.inspireyourway.com/?p=783&preview=true
    but the content is my homepage's http://www.inspireyourway.com
    Please help,
    I am using Firefox,
    and latest wordpress

  2. pete.ski
    Member
    Posted 1 year ago #

    Similar problem. When trying to preview a post, I get :"404 — Fancy meeting you here!" page. Same when typing in permalink of the post.
    Using either Firefox or Safari, same thing happens.

    Any idea anyone?

  3. Vincent Paul
    Member
    Posted 9 months ago #

    I'm having the same issue and I can't seem to figure it out. It would send me to my homepage instead of sending me to my blog post preview. I would like to know what could fix this!

  4. benarobinson
    Member
    Posted 9 months ago #

    I had a similar problem which I solved, thought I would share the solution because I had trouble finding one, and nobody discussed what ended up being my problem. I had slightly different symptoms than the 404 page and defaulting to the homepage -- in my case, everything was loading but the content. I tried a lot of things, but here was what fixed it:

    In my case, I had written the theme and was doing some custom query filtering with pre_get_posts to include two post types in the main query. For the "general" query which included all post types possible, I was using:

    $query->set(‘post_type’, get_post_types(”,’names’) );

    But! When get_post_types() has a blank in that first argument, post previews don’t work, because it only queries publicly available (published) posts. So, to allow previews correctly again, I had to change it to:

    if(is_preview()) {$query->set(‘post_type’, get_post_types(‘false’,'names’) ); } else { $query->set(‘post_type’, get_post_types(”,’names’) ); }

    It was a rather confounding problem since there was no actual "error," just a misunderstanding on my part of the need to have "false" as the value in that argument to allow all posts to be queried if preview was true.

    In the cases described here, I might suggest disabling plugins and checking to see that the WordPress URL and site URL match. In other cases, I know those things helped to solve the problem.

Topic Closed

This topic has been closed to new replies.

About this Topic