add_filter(‘the_content’, ‘…’) stops pagination from working

For posts is set up by loop (see setup_postdata()) it is split into parts and array of those parts is assigned to global $pages variable. Even if it’s not paginated this is still where data goes.

Then that variable is actually where get_the_content() looks for post content to process and output, not actual post object.

In your function you are overriding $content filter gives you (properly truncated to the page necessary) with complete content from post object. Typically you should stick with acting on data filter gives you, accessing global scope instead of that is very prone to issues like this.

tech