最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp config - How can I change preview URL?

programmeradmin1浏览0评论

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.

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.

Share Improve this question edited Nov 19, 2018 at 20:53 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Nov 19, 2018 at 20:44 bartbart 2251 gold badge2 silver badges9 bronze badges 1
  • 1 You can try the preview_post_link filter: developer.wordpress/reference/functions/… – czerspalace Commented Nov 19, 2018 at 21:07
Add a comment  | 

1 Answer 1

Reset to default 9

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/blog/p/$slug";
}

More info HERE and HERE.

发布评论

评论列表(0)

  1. 暂无评论