0

I am using a Wordpress plugin called RSS Retriever to display a RSS feed on this page Manchester United News What i am looking to do is display an advert (HTML) between every other feed title. Is there an easy way to do this without having to edit the plug in.

Sample Code

title="Man United ready to smash transfer record to sign star striker">Man United ready to smash transfer record to sign star striker</a><div class="wp_rss_retriever_container"><div class="wp_rss_retriever_metadata"><span class="wp_rss_retriever_date">Published: March 25, 2016 - 12:29 pm</span></div></div></div></li><li class="wp_rss_retriever_item"><div class="wp_rss_retriever_item_wrapper"><a class="wp_rss_retriever_title" target="_blank" href="http://footballnewsdaily.net/manchester-united/fenerbahce-plan-bid-for-manchester-united-ace-mata/"
0

you can add some code to the bottom of each feed post, this would give you the desired result. You can add this code to your functions.php or add it as a plugin

/** Add custom feed content footer
 * @param $content
 * @return string
 */
function add_feed_content($content) {

    if(is_feed()) {
    $post_type = get_post_type( get_the_ID() );

        $content .= '<footer>'.PHP_EOL;
        $content .= '<p>Some advert here</p>'.PHP_EOL;
        $content .= '</footer>'.PHP_EOL;
    }
    return $content;
}
add_filter('the_excerpt_rss', 'add_feed_content');
add_filter('the_content', 'add_feed_content');

edit: making the assumption you control the RSS feed, but thinking about your question more, maybe you don't

| improve this answer | |
  • I've added the PHP to the web page but it doesn't seem to have made any difference – Will Fisher Mar 23 '16 at 21:43
  • Do you control the RSS? If not you could maybe inject something using css and/or jQuery – Mat Benfield Mar 26 '16 at 13:20
  • Yes I do, Which do you think would be the easier option and what functions etc would i use for CSS – Will Fisher Mar 26 '16 at 13:32
  • If you control the source RSS adding my code above, that should work. That's certainly the easiest thing – Mat Benfield Mar 26 '16 at 13:35
  • I think it might be easier too use CSS as the PHP code which you posted wasn't working correctly. Also all the feed items have a similar HTML (which I've posted now in the original Question), if you could point me in the right direction for a CSS code that would be a great help – Will Fisher Mar 26 '16 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.