I have a WordPress blog pulling an RSS feed from Flickr. A plugin is grabbing the <description>
tag in the XML and creating a pending post. I have a PHP function which modifies the embedded image and I'm trying to, in the same function, remove some extra text. I'm using str_replace
and an array of strings (as suggested here).
My problem is that the first string I am trying to replace ($att[0]
) is not replaced by my function.
rss.xml
<description>
<!-- This first string is always the same, I'd like to remove it -->
<p><a href="https://someUrlHere.com">username</a> posted a photo:</p>
<p><a href="https://linkToimage.com"><img src="https://imgSrc.jpg" /></a></p>
</description>
functions.php
function edit_content($content) {
// Set the array of strings
// $att[0] is not replaced by the function. Why?
// $att[1] is replaced
$att = array('<p><a href=\"https://www.flickr.com/people/bennettscience/\">bennettscience</a> posted a photo: </p>', '_m.jpg');
$replace = array(' ', '_b.jpg');
// Modify the content and return to the post.
$content = str_replace($att, $replace, $content);
return $content;
}
add_filter( 'the_content', 'edit_content');
I guess I have two questions:
- Is there something obvious I'm missing in the function?
- How can I debug the script? There are no PHP errors given when I update the file in WordPress. I'm not too familiar with PHP at this point.