Skip to content

Instantly share code, notes, and snippets.

@konratnox
Created May 6, 2019 10:13
Show Gist options
  • Save konratnox/798bcb559c23c436100751a4b1ef874f to your computer and use it in GitHub Desktop.
Save konratnox/798bcb559c23c436100751a4b1ef874f to your computer and use it in GitHub Desktop.
$jsonItems = [
'@context' => 'http://schema.org',
'@type' => 'BreadcrumbList',
'itemListElement' => []
];
$jsonItems['itemListElement'][] = [
'@type' => 'ListItem',
'position' => $index + 1,
'item' => [
'@id' => $link,
'name' => strip_tags(html_entity_decode($title))
]
];
echo '<script type="application/ld+json">
'.json_encode($jsonItems, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES).'
</script>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment