Hello!
I’m afraid you can’t manage this via a theme template file. The WordPress query must already be initialized before that file gets loaded, and we use that initialization to determine SEO support for a possible 301 redirect. At that very moment, we cache the filter’s return value.
So, I recommend using the (child-)theme functions.php file or a custom plugin instead.
Since TSF v4.0, we have a new filter meant for this type of alterations:
the_seo_framework_query_supports_seo
It will look a little bit like this:
add_filter( 'the_seo_framework_query_supports_seo', function( $supported ) {
$tsf = the_seo_framework();
// This TSF method also works in the admin area, and prevents ID collision with terms.
if ( $tsf->is_singular() ) {
// Define your excluded page IDs here.
$excluded_ids = [ 42, 9001 ];
// This TSF method supports page-as-archive pages, like blog and shop pages.
if ( in_array( $tsf->get_the_real_ID(), $excluded_ids, true ) ) {
$supported = false;
}
}
return $supported;
} );
If you want to disable it in the admin area as well, you must use a filter that’s not really meant for this. Please note that single-post-exclusions won’t work in the list edit loop (Post overview) via this filter, but it will work for the post-edit screens:
add_filter( 'the_seo_framework_supported_post_type', function( $supported ) {
// Use the same code as above here...
} );
I hope that these updated integrations works well for you 🙂 Cheers!
Thank you so much! I just tested the code and it just works!
Last time I checked the whole documentation, this new filter was not there. Is the documentation currently being developed?
Can I donate $10 to you or should I just buy the cheaper membership? Your work on this plugin is really awesome!
No problem! Yes, I still need to update the docs, I haven’t found the time to do that yet. 🙁
Don’t worry about donating; we’re a business based on voluntary work. It’s your money, so getting a license is up to you! Thank you for considering 🙂