aioseo_schema_output

Purpose

This filter can be used to filter the JSON schema that All in One SEO outputs.

Arguments (1)

  1. $graphs (array) – The graphs with their properties as multidimensional arrays.

Example code snippets

The code snippet below is just an example of how this filter can be used. In the example below, the BreadcrumbList graph is removed from the output.

add_filter( 'aioseo_schema_output', 'aioseo_filter_schema_output' );

function aioseo_filter_schema_output( $graphs ) {
    foreach ( $graphs as $index => $graph ) {
		if ( 'BreadcrumbList' === $graph['@type'] ) {
			unset( $graphs[ $index ] );
		}

		foreach ( $graph as $key => $value ) {
			if ( 'breadcrumb' === $key ) {
				unset( $graphs[ $index ][ $key ] );
			}
		}
	}
	return $graphs;
}

The code snippet below is an example of how to remove the Article graph from Posts:

add_filter( 'aioseo_schema_output', 'aioseo_filter_schema_output' );

function aioseo_filter_schema_output( $graphs ) {
	if ( is_singular( 'post' ) ) {
 	   foreach ( $graphs as $index => $graph ) {
			if ( 'Article' === $graph['@type'] ) {
				unset( $graphs[ $index ] );
			}
		}
	}
	return $graphs;
}