How can I change preview URL?

You can do something like this, add to functions.php add_filter( ‘preview_post_link’, ‘the_preview_fix’ ); function the_preview_fix() { $slug = basename(get_permalink()); return “http://www.mywebsite.com/blog/p/$slug”; } More info HERE and HERE.

How are WordPress draft previews generated?

Yes, this one is a duplicate of this post. I will provide little different examination mechanism. You use wp cli export before and after you preview the minimal asdf post. wp export You don’t save anything, you just preview. Make sure you have super big autosave interval. define( ‘AUTOSAVE_INTERVAL’, 1000000 ); The default interval is … Read more

Post/Page Preview Template

You could use the conditional is_preview() to add a bit of extra content. For instance, you could put this at the very top of your single.php right after the header is called – or you could put it in your header.php file if you want it shown at the very top of the page: <?php … Read more

View homepage in a preview mode

I think you can set your post to private to view it privately on the homepage. Once you change the visibility to private, the post or page status changes to “Privately Published” as shown. Private posts are automatically published but not visible to anyone but those with the appropriate permission levels (Editor or Administrator). See … Read more

Passing current cookies in wp_remote_get to get Draft Post Preview

I rarely deal with cookies and not sure about complete mechanics there, but here is basic working example of passing current user’s cookies to retrieve preview page source: $preview_link = set_url_scheme( get_permalink( $post->ID ) ); $preview_link = esc_url( apply_filters( ‘preview_post_link’, add_query_arg( ‘preview’, ‘true’, $preview_link ) ) ); $cookies = array(); foreach ( $_COOKIE as $name … Read more

Post preview mechanism architecture

Even if you hit just one button for “Preview” it may ends in 2 different “routes”. The one is something like http://example.com/postname/?preview=true The second is something like: http://example.com/postname/?preview_id=152&preview_nonce=xxx&preview=true so the first contains preview query argument, the second contains preview_id preview_nonce preview query arguments. preview query argument tells WordPress to allow visualization of non-published posts to … Read more

Approve post directly from preview mode?

Here is something i have laying around: <?php /* Plugin Name: Approve From preview Plugin URI: http://en.bainternet.info Description: Approve from privew is Plugin that lets yo approve posts (draft and pending) from the preview itself. Version: 0.1 Author: Bainternet License: Copyright 2012 Bainternet ([email protected]) This program is free software; you can redistribute it and/or modify … Read more