How to disable global Organization/LocalBusiness schema on archive pages?

Hello,

I am using the ClassicSEO plugin and need some help with the schema output.

The Problem:
The plugin correctly outputs Organization and LocalBusiness schema, but it does so on every page of my website, including tag and category archives. According to Google’s Rich Results Test, this schema appears on my tag archive pages.

My Goal:
I want to disable this global Organization/LocalBusiness schema on all archive pages (tags, categories, etc.) so that my own custom function can output a more appropriate CollectionPage schema on these pages. I only want the Organization/LocalBusiness schema to appear on my homepage or contact page.

What I have tried so far (without success):

  1. Plugin Settings: I have set the “Contact Page” and “About Page” in the “Local SEO” settings, but this did not stop the schema from appearing on archive pages.
  2. remove_action in functions.php: I used Query Monitor and found the function Classic_SEO\Frontend\Add_Attributes->add_attributes() running on the wp_head hook with priority 99. My attempts to remove it with a custom function have failed.
  3. Output Buffering: I even tried to remove the script from the final HTML output using ob_start() and preg_replace(), but this also failed to remove the plugin’s schema.

My Question:
Is there a specific setting I am missing, or what is the correct PHP filter or action I should use in my functions.php to prevent the Organization and LocalBusiness schema from being output on archive pages?

Thank you for your help!

This is probably one for @Simone

I’m not so sure this will solve your problem, but this snippet (I’ve tested using a mu-plugin) removes Classic_SEO\Frontend\Add_Attributes->add_attributes().

add_action( 'wp', function () {
	if( ! is_archive() ) {
		return;
	}
	global $wp_filter;
	foreach( $wp_filter[ 'wp_head' ][ '99' ] as $key => $value ) {
		if ( ! str_ends_with( $key, 'add_attributes' ) ) {
			continue;
		}
		if ( get_class( $value[ 'function' ][0] ) !== 'Classic_SEO\Frontend\Add_Attributes' ) {
			continue;
		}
		remove_action( 'wp_head', $key, 99 );
	}
});

Note: edited to hook later and check if the page in an archive page.