WordPress 预览_帖子_链接

发布于 2024-12-25 01:05:30 字数 693 浏览 1 评论 0原文

我试图在 WordPress 上发布时更改默认的“预览帖子”按钮,因为该网站安装了被黑客入侵的 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";
}

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";
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

被翻牌 2025-01-01 01:05:30
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";
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文