Howdy everyone, I'm running into a frustrating issue when adding a filter to the_content. While I know the code executes, the modified content doesn't replace the original. I've hit a wall. I'm sure I'm missing something obvious, so I would appreciate any pointers.
Here are the two filters from my child theme's function.php, neither of which returns the new version of $content, though when I add an echo 'test'; anywhere within the functions, that is output, so I know these are being executed. If it matters, my child theme is based on the most recent version of the Genesis framework.
/*! Link Twitter @usernames */
function linktwitterhandles($content) {
$content = preg_replace('/([\.|\,|\:|\Á|\À|\>|\{|\(]?)@{1}(\w*)([\.|\,|\:|\!|\?|\>|\}|\)]?)\s/i', "$1<a href=\"http://twitter.com/$2\" class=\"tweet-username\">@$2</a>$3 ", $content);
return $content;
}
add_filter('the_content', 'linktwitterhandles', 19);
add_filter('the_excerpt', 'linktwitterhandles', 19);
add_filter('get_comment_text', 'linktwitterhandles', 19);
/*! Post Tweaks for Pinterest */
function custom_pinterest_content($content) {
if ( is_syndicated() && has_tag('pinterest') ) {
$content = str_replace('<img', '<a href="'. get_syndication_permalink() . '"><img', $content);
$content = str_replace('/></p>', '/></a></p>',$content);
}
return $content;
}
add_filter('the_content','custom_pinterest_content',11);
In both samples, when I echo $content right before I return it, I see double results, the first of which is the modified version, the second is the original. I've changed the execution order, using values as low as 1 and as high as 2000 for both add_filter lines.
Any thoughts?