仅可访问 WordPress 网站上的 Feed URL [英] Make Only Accessible to Feed URL on a WordPress Site

查看:30
本文介绍了仅可访问 WordPress 网站上的 Feed URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以编写一个不显示任何内容而只让访问者访问提要 URL 的插件.管理员也应该可以访问管理页面.

I'm wondering if it is possible to write a plugin which shows nothing but only let the visitor access the feed url. The admin page should be accessible by the administrator as well.

这个想法的背景是我编写了一个自定义提要生成器并在 WordPress 网站中实现了它.由于该站点仅用于提要,因此除了提要输出之外,我想让该站点对公众不可见.

The background of this idea is that I've written a custom feed generator and implemented it in a WordPress site. Since the site is only for the feeds, I'd like to make the site invisible to the public except the feed outputs.

我知道有维护模式仅限会员 插件.问题是维护模式禁止访问提要,仅限会员模式禁止一般访问者.

I'm aware that there are Maintenance Mode and Members Only plugins. The problem is that the maintenance mode prohibits feed access and the member only mode bans general visitors.

所以我想知道是否有一种简单的方法可以做到这一点.我想避免编辑 mod_rewrite,因为我打算尽可能将其作为插件.如果没有 mod_rewrite 不现实,我会尝试编辑 mod_rewrite.

So I'm wondering if there is a simple way to do this. I'd like to avoid editing mod_rewrite because I'm planning to make it as a plugin if possible. If it is not realistic to do it without mod_rewrite, I will try editing mod_rewrite.

感谢您的意见.

推荐答案

如果你不想渲染任何东西,可以使用 template_redirect 钩子轻松解决这个问题.例如:

If you never want anything to render this could easily be fixed using the template_redirect hook. For example:

function stop_rendering() {
    exit;
}
add_action( 'template_redirect', 'stop_rendering');

这篇关于仅可访问 WordPress 网站上的 Feed URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆