I can't preview post's change once they are published

The preview function works fine when posts are just draft. The url looks like this : http://exemple.domain.com/blog/?p=12preview=true

Then when I pubish my posts, let's say I want to change something and preview it, the url looks like this : http://exemple.domain.com/blog/my-article-title/?preview=truepreview_id=12preview_nonce=514e88946apost_format=standard

The problem is it does reflect any changes ...

I use WordPress 3.9.2 running Twenty Fourteen theme without any plugins

EDIT

I've turn the permalink to default and it resolve the problem. But I need it to work using the pretty url ... Thanks for your help

Topic previews publish draft Wordpress

Category Web


You need to define the %postname% permalink and be sure that the .htaccess is modified.

If your .htaccess has blocked access you can do it manually.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

You can see more info at the Codex, just look for "Using "Pretty" permalinks".


This is probably not the best way to do it since it wont persist after wordpress updates (but hopefully the update will correct it.

In wp-admin/includes/post.php ,edit the post_preview() function just before returning the apply_filters( 'preview_post_link', $url ); put the following code:

//ORIGINAL
//$url = add_query_arg( $query_args, get_permalink( $post->ID, true ) );

//CHANGES to make the preview work even with postname in the URL
$query_args['p'] = $post->ID;
$url = add_query_arg( $query_args, get_permalink( $post->ID, true ) );
$url = str_replace('%postname%/', '', $url); 
//END CHANGES

But still if there is any way to make it better ?

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.