Hi Nikodemsky!
That filter defeats how TSF curates its canonical URL. I can now add random stuff to any of your paginated pages, post those links, and Google/Bing will index them. Less nefariously, your site might generate those links by accident. The moment you output a canonical URL, you “avouch” that the requested URL is “purposive.” So, it’d actually be better to disable the canonical URL so search engines can decide for themselves if a link is duplicated/intended.
Please note that TSF v4.2.0 had a regression where it didn’t correctly generate paginated URLs for categories — I resolved this in TSF v4.2.1 two weeks later. So, I recommend updating first.
If you already use TSF v4.2.1+, then it seems the pagination you implemented is not registered with WordPress, but only with the plugin generating it — Kadence Blocks is one offender that comes to mind.
Consider using WordPress’s native pagination, which will work with any theme, (SEO) plugin, block, etc.
Alternatively, I recommend using this filter:
add_filter( 'the_seo_framework_rel_canonical_output', function( $url, $id ) {
if ( is_paged() )
return '';
return $url;
}, 10, 2 );
I hope this helps! Cheers ??