将下面这段代码添加到网站根目录下functions.php文件中,添加到文件的最后即可。如果你添加了没有生效,先清空缓存试试,再看看你使用的主题模板是否有单独的functions.php自定义文件调用。

function insert_after_first_paragraph($content) {
if (!is_single()) return $content;
$content_parts = explode('

', $content); if (count($content_parts) > 1) { $inserted_content = '
这里改成你的广告代码或超链接
'; $content_parts .= '

' . $inserted_content; $content = implode('

', $content_parts); } return $content; } add_filter('the_content', 'insert_after_first_paragraph'); function add_custom_styles() { echo '';

} add_action(‘wp_head’, ‘add_custom_styles’);```

版权声明

作者: 梦随乡兮

链接: https://imsxx.com/posts/wordpress-post-ad/

许可证: CC BY-NC-SA 4.0

本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。请注明出处,非商业使用,并保持相同许可。

开始搜索

输入关键词搜索文章内容

↑↓
ESC
⌘K 快捷键