• Resolved johnbenedict

    (@johnbenedict)


    In your FAQs you give the following code to remove the default schema markup:

    remove_action( 'amp_post_template_head', amp_post_template_add_schemaorg_metadata' );

    It does not appear to work. Here is what I am trying:

    add_action( 'amp_post_template_head', 'my_amp_customizations' );
    function my_amp_customizations() {
      remove_action( 'amp_post_template_head', 'amp_print_schemaorg_metadata' );
      remove_action( 'amp_post_template_head', 'amp_post_template_add_schemaorg_metadata' );
    }

    Note that I am trying both:
    amp_post_template_add_schemaorg_metadata and amp_print_schemaorg_metadata

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Weston Ruter

    (@westonruter)

    OK, yeah, that’s incorrect in the FAQ.

    The right way to remove the default Schema.org should be to do this:

    add_filter( 'amp_schemaorg_metadata', '__return_empty_array' );

    But, I see this isn’t working as expected either as it results in:

    <script type="application/ld+json">[]</script>

    But that should still work for your intents and purposes. I’ll file an issue to fix this, to ensure this works.

    Alternatively, you can do this which will prevent that from happening, but it isn’t as ergonomic:

    add_filter( 'amp_optimizer_config', function( $config ) {
    	$config['transformers'] = array_diff(
    		$config['transformers'],
    		[ 'AmpProject\AmpWP\Transformer\AmpSchemaOrgMetadata' ]
    	);
    	return $config;
    } );

    Nevertheless, if you add a Schema.org metadata script yourself then the AMP plugin should avoid adding one of its own.

    Please subscribe to this issue for updates: https://github.com/ampproject/amp-wp/issues/4783

    @jamesosborne Please update the FAQ accordingly.

    Thread Starter johnbenedict

    (@johnbenedict)

    Thank you @westonruter! I really appreciate the fast response.

    I’ll take the less ergonomic solution for now. Looking forward to the update.

    @johnbenedict Thanks for highlighting this. Corrected now on the plugins FAQs page.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Remove schema markup’ is closed to new replies.