Skip to content

Instantly share code, notes, and snippets.

@fumikito
Created October 27, 2025 08:04
Show Gist options
  • Save fumikito/76a488cecd44ea9f762eb39be897ba01 to your computer and use it in GitHub Desktop.
Save fumikito/76a488cecd44ea9f762eb39be897ba01 to your computer and use it in GitHub Desktop.
Breadcrumb NavXTのマークアップを構造化データに対応させる
<?php if ( function_exists( 'bcn_display' ) ) : ?>
<nav id="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList">
<?php
// アウトプットバッファで出力を取得
ob_start();
bcn_display();
$bcn = ob_get_clean();
// 古いプロパティを書き換える
foreach ( [
'property="itemListElement"' => 'itemprop="itemListElement"',
'typeof="ListItem"' => 'itemscope itemtype="https://schema.org/ListItem"',
' typeof="WebPage"' => '',
'property="item"' => 'itemprop="item"',
'property="name"' => 'itemprop="name"',
'property="position"' => 'itemprop="position"',
] as $search => $repl ) {
$bcn = str_replace( $search, $repl, $bcn );
}
echo $bcn;
?>
</nav>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment