WordPress的preview_post_link [英] Wordpress preview_post_link
问题描述
我正在尝试在wordpress上发布时更改默认的"preview post"按钮,因为该网站的wordpress安装遭到黑客入侵,并且帖子的预览与预期的位置不符.
我找到了钩子preview_post_link
,现在我只是想弄清楚如何制作一个可以解决此问题的小插件.
我不知道该怎么办以及为什么要在这里发帖,是使用add_filter
更改链接
add_filter( 'preview_post_link', 'the_preview_fix' );
function the_preview_fix() {
return;
}
我所要做的就是不要转到其当前链接,而转至www.website.com/blog/p/the-slug
,即使草稿帖子未出现在实时站点上,该链接仍会将我带到一个生成的页面:) >
在此先感谢您提供的所有帮助
编辑已修复!
add_filter( 'preview_post_link', 'the_preview_fix' );
function the_preview_fix() {
$slug = basename(get_permalink());
return "http://www.mywebsite.com/blog/p/$slug";
}
add_filter( 'preview_post_link', 'the_preview_fix' );
function the_preview_fix() {
$slug = basename(get_permalink());
return "http://www.mywebsite.com/blog/p/$slug";
}
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";
}
add_filter( 'preview_post_link', 'the_preview_fix' );
function the_preview_fix() {
$slug = basename(get_permalink());
return "http://www.mywebsite.com/blog/p/$slug";
}
这篇关于WordPress的preview_post_link的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!