Answers:
以chrisguitarguy的答案为基础,这里是一个简短的代码段,您可以放入主题的functions.php文件来完成工作
add_action('template_redirect', 'wpse69948_archive_disabler');
function wpse69948_archive_disabler()
{
if(is_tag() || is_category() || is_date() || is_author())
{
global $wp_query;
$wp_query->set_404();
}
}
我为此编写了一个插件 -需要进行一些更新,但仍然可以正常使用。
基本上,您在WordPress知道请求的页面之后(例如template_redirect
),在某个地方挂了钩,使用条件功能之一,然后使用$wp_query->set_404()
或只是将用户重定向到您选择的页面。
要禁用类别,标签,作者和日期档案:
<?php
add_action('template_redirect', 'wpse69948_tag_disabler');
function wpse69948_tag_disabler()
{
if(is_tag() || is_category() || is_date() || is_author())
{
global $wp_query;
$wp_query->set_404();
}
}