How can I change the preview URL in WordPress?

When creating a post in WordPress, there is a Preview button which takes you to the draft view. Because I have a custom integration of WordPress and don’t use a theme, I would like to change the URL of the preview link. Is this possible? How?

Regarding the custom implementation, WordPress posts are integrated in another framework. I do this by setting WP_USE_THEMES to false, loading wp-config.php and directly accessing the posts using WP_Query(). This means I am bypassing any WordPress theme that is set.

1
1

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.

Leave a Reply

Your email address will not be published. Required fields are marked *