1

I'm trying to write a plugin for Feedwordpress that filters html from the incoming feeds. So far I have managed to hook it to the right place, but the function completely wipes all content (and it seems to cause issues with the Feedwordpress plugin). Where am I going wrong here?

add_filter(
    /*hook=*/ 'syndicated_item_content',
    /*function=*/ 'fwp_rss_regex',
    /*order=*/ 10,
    /*arguments=*/ 1
);

function fwp_rss_regex ($post) {
    $content = $post->post_content();   
    $content = preg_replace('\<[^\>]*\>', '', $content);
    return $content;
}
0

Fixed it with:

function fwp_rss_regex ($content) {
$content = preg_replace('/\<[^\>]*\>/i','',$content);
return $content;
}

This solved the problem: 1) Because $content was the item I wanted I wanted to pass through fwp_rss_regex, 2) Because I fixed my preg_replace with /______/i , and 3) I realised $content = $post->post_content(); was either a superfluous (though maybe valid) command, or was it doing nothing in at all.

  • Please explain why this solves the problem. – kaiser Jul 28 '15 at 14:06
  • This solved the problem: 1) Because $content was the item I wanted I wanted to pass through fwp_rss_regex, 2) Because I fixed my preg_replace with /______/i , and 3) I realised $content = $post->post_content(); was either a superfluous (though maybe valid) command, or was it doing nothing in at all. – GBin Jul 30 '15 at 8:46
  • Add your explanation from the comment above as an edit to your answer where it belongs :-). Also accept your own answer by clicking on the arrow next to your answer. It will go green which means the answer is accepted as the best solution – Pieter Goosen Aug 17 '15 at 12:41

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.