Ive created a simple plugin which changes the preview link to the correct location as its a custom Wordpress install into an existing site framework.
Using 'preview_post_link' filter I can change the link successfully to say:
http://www.domain.com/wp-custom.php?p=123456&preview=true
This works perfectly upon hovering over and inspecting the a tag:
<a class="preview button" href="http://www.domain.com/wp-custom.php?p=123456&preview=true" target="wp-preview" id="post-preview">Preview</a>
Right click and open in a new window/tab and it opens fine. Click the actual button though and it fails churning out the url in the address bar of:
http://www.domain.com/?p=123456&preview=true
Not quite sure what is happening or a workaround? Only thing I can think of is maybe some sort of JQuery is ran by wordpress on .preview or #post-preview which is affecting the behavior when the button is clicked directly.
Any ideas of how to remedy would be greatly appreciated. Many thanks.
Updated to show the simple method for amending the wordpress preview links:
function custom_change_preview_link($link) {
return preg_replace('/\?/','wp-custom.php?',$link);
}
add_filter( 'preview_post_link', 'custom_change_preview_link' );
add_filter( 'preview_page_link', 'custom_change_preview_link' );
Preview
button link?/wp-includes/js/autosave.js
. I was not able to overwrite$('#post-preview').click(function(){});
. Maybe removing and replicating thepost_submit_meta_box
?