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

1 Answer 1

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.

3
  • Please explain why this solves the problem. Commented Jul 28, 2015 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. Commented Jul 30, 2015 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 Commented Aug 17, 2015 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.