Wordpress preview_post_link

馋奶兔 提交于 2019-12-07 05:23:25

问题


I am trying to alter the default "preview post" button when posting on wordpress as the site has a hacked wordpress install and the posts previews are not where they are suppose to be.

I found the hook preview_post_link now I am just trying to figure out how to make a little plugin that will fix the problem.

What I don't know how to do and why I am posting here is, using the add_filter to change the link

add_filter( 'preview_post_link', 'the_preview_fix' );

function the_preview_fix() {

    return;
}

all I need it to do is instead of going to its current link go to www.website.com/blog/p/the-slug as even though the draft post doesn't appear on the live site the link will still take me to a generated page :)

Thanks in advance for any and all help received

EDIT FIXED IT!

add_filter( 'preview_post_link', 'the_preview_fix' );

function the_preview_fix() {
    $slug = basename(get_permalink());
    return "http://www.mywebsite.com/blog/p/$slug";
}

回答1:


add_filter( 'preview_post_link', 'the_preview_fix' );

function the_preview_fix() {
    $slug = basename(get_permalink());
    return "http://www.mywebsite.com/blog/p/$slug";
}


来源:https://stackoverflow.com/questions/8741485/wordpress-preview-post-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!