防止搜索引擎索引所有帖子
Preventing search engines from indexing all posts
我在 Wordpress 网站上工作,我在其中使用 post 为艺人创建巡演日期列表。使用 ACF,我在 table 中设置了字段,客户只需输入日期、位置、link 购买门票等。
table 就是我需要访客看到的全部内容。 single.php 创建的实际 post 不会被设置样式,也不应该被看到。
我想防止有人搜索艺术家和城市并遇到 post。
我可以在 robot.txt 文件中放入插件或禁止吗?
感谢任何帮助。在每个人都想被搜索引擎注意到而我想对他们隐藏一些东西的时代有点有趣!
将下面的代码添加到您的主题中functions.php:
add_action('wp_head', 'your_prefix_noindex_nofollow');
function your_prefix_noindex_nofollow() {
if(is_single()){
echo '<meta name="robots" content="noindex,nofollow"/>';
}
}
您也可以将函数名称中的 "your_prefix" 更改为任何您喜欢的名称。它会按原样工作,但最好在所有函数名称中使用相同的前缀。
我在 Wordpress 网站上工作,我在其中使用 post 为艺人创建巡演日期列表。使用 ACF,我在 table 中设置了字段,客户只需输入日期、位置、link 购买门票等。
table 就是我需要访客看到的全部内容。 single.php 创建的实际 post 不会被设置样式,也不应该被看到。
我想防止有人搜索艺术家和城市并遇到 post。
我可以在 robot.txt 文件中放入插件或禁止吗?
感谢任何帮助。在每个人都想被搜索引擎注意到而我想对他们隐藏一些东西的时代有点有趣!
将下面的代码添加到您的主题中functions.php:
add_action('wp_head', 'your_prefix_noindex_nofollow');
function your_prefix_noindex_nofollow() {
if(is_single()){
echo '<meta name="robots" content="noindex,nofollow"/>';
}
}
您也可以将函数名称中的 "your_prefix" 更改为任何您喜欢的名称。它会按原样工作,但最好在所有函数名称中使用相同的前缀。