在WordPress的Feed中插入广告

实现方法很简单,只需要将下面的代码放到function.php里即可:

< ?php
function insertAds($content) {
    $content = $content.'
广告位置
'; return $content; } add_filter('the_excerpt_rss', 'insertAds'); add_filter('the_content_rss', 'insertAds'); ?>

使用原理:
我们首先建立一个函数 insertAds() 这个函数包含一个内容,就是盛放广告代码的 $content ,接着使用 add_filter() 重写 the_content_rss() 然后重新利用 the_excerpt_rss() 输出 Feed 内容。

Comments

3 responses to “在WordPress的Feed中插入广告”

  1. bolo Avatar

    不够详细,不过学习了

  2. laobian Avatar

    能说的再详细点吗?

    1. 酋 长 Avatar

      可以google一下。文章很多的。