要禁止WordPress自动添加分段标签,你可以尝试以下方法:
方法一:编辑主题文件
1. 登录到你的WordPress主题的后台文件管理器或使用FTP客户端登录到你的网站主机。
2. 导航到位于主题文件夹中的`wp-includes/post-template.php`文件(通常在`wp-content/themes/your-theme/wp-includes/post-template.php`)。
3. 在该文件中搜索以下代码段(可能位于文件的开头部分):
```php
function get_content() {
$content = apply_filters('the_content', get_the_content($in_more_link_class, $unEscape));
$content = str_replace(']]>', ']]>', $content);
return $content;
}
```
4. 在上述代码段的开头添加以下代码:
```php
remove_filter('the_content', 'wpautop');
```
这将移除`wpautop`过滤器,从而禁止WordPress自动添加分段标签。
5. 保存文件并上传到服务器。
方法二:使用插件
1. 在WordPress后台导航菜单中,选择"插件" > "添加新插件"。
2. 在搜索框中输入"Disable Auto Paragraphs"或类似的关键词,找到并安装适合的插件。
3. 激活插件,并根据插件的设置指南进行配置。
4. 保存并发布插件的设置。
无论你选择哪种方法,都要确保在修改或添加功能之前备份你的网站以防止意外情况发生。