跳到正文
梦随乡兮
Go back

在wordpress所有文章第二段落中插入广告

编辑此页

将下面这段代码添加到网站根目录下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 ’

编辑此页
Share this post on:

Previous Post
Hello World - 我的第一篇文章
Next Post
1panel开启WordPress的redis缓存流程 流程优化版