WordPress :AIOSEO 外掛不要輸出 breadcrumbList Schema Data

AIOSEO 預設都會輸出 breadcrumbList 這個麵包屑 Schema Data,但輸出的麵包屑又是錯誤的,很討厭。

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;
}

在function.php 加入上面程式碼,就可以禁止 AIOSEO 輸出 breadcrumbList Schema Data 了。

參考:

How to disable Breadcrumbs in aioseo-schema