Skip to content

Instantly share code, notes, and snippets.

Created September 25, 2012 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/df50e543677392ab60cd to your computer and use it in GitHub Desktop.
Save anonymous/df50e543677392ab60cd to your computer and use it in GitHub Desktop.
function easyrotator_update_search_content($content)
{
if (is_search())
{
$content = preg_replace_callback('|(<!-- Begin DWUser_EasyRotator -->)(.*?)(<!-- End DWUser_EasyRotator -->)|si', 'easyrotator_update_search_content_callback', $content);
}
return $content;
}
function easyrotator_update_search_content_callback($matches)
{
$content = $matches[2];
preg_match('|<img.*?\ssrc="([^"]+)".*?/?>|si', $content, $submatches);
return $matches[1] . $submatches[0] . $matches[3];
}
add_filter('the_content', 'easyrotator_update_search_content', 1000);
add_filter('the_excerpt', 'easyrotator_update_search_content', 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment