3

The preview function works fine when posts are just draft. The url looks like this : http://exemple.domain.com/blog/?p=12&preview=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=true&preview_id=12&preview_nonce=514e88946a&post_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

  • Do you have any caching on? – Steven Jones Aug 22 '14 at 11:13
  • @StevenJones no I don't – 0x1gene Aug 22 '14 at 11:13
0

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 ?

0

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".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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