WordPressのAll in One SEOは自動でパンくずの構造化データを出力してくれる。
大変ありがたいんだけど、自前でプログラムを用意する場合や、他のプラグインを使いたくてちょっと邪魔になる場合もある。
しかし管理画面から構造化データの出力をオフにすることはできないので、プログラムで書いてやる必要があるのであった。。
実装
こう!
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 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; } | 
なお、All in One SEOが吐き出す構造化データを全部消したいときは、こう!
| 1 2 3 4 5 6 7 8 | add_filter( 'aioseo_schema_disable', 'aioseo_disable_schema_products' ); function aioseo_disable_schema_products( $disabled ) {    if ( is_singular( 'product' ) && aioseo()->helpers->isWooCommerceActive() ) {       return true;    }    return $disabled; } | 
以上、現場からでした。





