As you can see in the Codex, the filter actually has 2 arguments, which needs to be stated:
add_filter( 'the_title', function ( $title, $id = null ) {
return preg_replace('#(\s{3})#', '…', $title);
}, 10, 2 );
You could as well just use a placeholder that you replace on the fly – might be easier.
In case above does not work, you might want to give it try exactly before you call it:
$filters = $GLOBALS['wp_filter']['the_title'];
foreach ( $filters as $priority => $filter ) {
remove_all_filters('the_title', $priority);
}
add_filter( 'the_title', function ( $title, $id = null ) {
return preg_replace('#(\s{3})#', '…', $title);
}, 10, 2 );
the_title();
If ^ above works, then you have a problem with removing the filters properly. You might want to just var_dump($GLOBALS['wp_filter']['the_title'];)
above the call for the_title()
and then take a look of what was left in and care about that.