求方法。谢谢 |
网友回复:
注册: 直接数据库插?
怪人: 啊!求方法
似毛非毛: 插件?
怪人: 是在文章中间还是顶部尾部
maki5040: 如果没有采集,用火车,如果已经采集了。这个估计要用命令。这就是在我的知识储备区以外的。
一念瞬间: 插哪里呢,内容前后的话就粗暴点直接写死到模板。
helwo: 大佬,不能写在头部或尾部。一定要插入文章表里才行
点点: 给你一段插入广告的,插入文字也一样的用法,放在functions.php就可以。 function prefix_insert_after_paragraph( $ads, $content ) { if ( ! is_array( $ads ) ) { return $content; } $closing_p = ‘
‘; $paragraphs = explode( $closing_p, $content ); foreach ($paragraphs as $index => $paragraph) { if ( trim( $paragraph ) ) { $paragraphs[$index] .= $closing_p; } $n = $index + 1; if ( isset( $ads[ $n ] ) ) { $paragraphs[$index] .= $ads[ $n ]; } } return implode( ”, $paragraphs ); } add_filter( ‘the_content’, ‘prefix_insert_post_ads_array’ ); function prefix_insert_post_ads_array( $content ) { if ( is_single() && ! is_admin() ) { $content = prefix_insert_after_paragraph( array( // 格式说明: ‘段落号’ => ‘要插入的内容’, ‘1’ => ‘
这里插入你的文字
‘, ‘2’ => ‘
这里插入你的另一段文字
‘, ), $content ); } return $content; }复制代码
怪人: 只是在头尾, 可以写进模板 在文章中间, 可以写进数据库, 或者js修改, 或者写个中间件
注册: 嗯,求写进数据库方法 谢谢