In the function below, the save_content function runs, but the doReplace does not (echo
"This is the doReplace" never shows. Any ideas why?
add_action('content_save_pre', 'save_content');
function save_content($content){
global $post;
$mykeyword = rseo_getKeyword($post);
$mykeyword = preg_quote($mykeyword, '/');
$content = preg_replace_callback("/\b($mykeyword)\b/i","doReplace", $content);
return $content;
}
function doReplace($matches)
{
echo "This is the doReplace";
die;
}
global $post, but at the timecontent_save_preruns, no$postobject exists (since you are right before saving it). Could this be your problem? – Jan Fabry Nov 4 '10 at 15:52rseo_getKeyword()returns there? Have you triedpreg_replace_callback()with a fixed keyword? – Jan Fabry Nov 4 '10 at 18:25