Skip to content

Instantly share code, notes, and snippets.

@temsool
Last active June 1, 2023 01:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save temsool/acc678c254680e8536495c13e306678a to your computer and use it in GitHub Desktop.
Save temsool/acc678c254680e8536495c13e306678a to your computer and use it in GitHub Desktop.
schema agespace
<?php
add_filter( 'wpseo_schema_webpage', 'change_schema_ref', 11, 2 );
function change_schema_ref( $piece ) {
$linkstring ='https://www.agespace.org'.$_SERVER['REQUEST_URI'];
$piece['@id']=$linkstring;
$piece['url']=$linkstring;
$piece['breadcrumb']['@id']=$linkstring;
return $piece;
}
add_filter( 'wpseo_schema_breadcrumb', 'replace_domain_name_to_breadcrumb_schema', 11, 2 );
/**
* Replace domain name in the breadcrumb schema piece individually.
*
*
* @param array $piece Schema.org Breadcrumb data array.
* @return array Altered Schema.org Breadcrumb data array.
*/
function replace_domain_name_to_breadcrumb_schema( $piece ) {
$linkstring ='https://www.agespace.org'.$_SERVER['REQUEST_URI'];
$piece['@id'] = $linkstring;
return $piece;
}
?>
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "CollectionPage",
"@id": "https://www.agespace.org/services/home-care/essex",
"url": "https://www.agespace.org/services/home-care/essex",
"name": "Home Care in Essex | Domiciliary & Live-in Care Services",
"isPartOf": {
"@id": "https://www.agespace.org/#website"
},
"description": "Compare Essex home care agencies & providers in our trusted guide. Domiciliary care, live-in care & specialist Dementia care in Essex",
"breadcrumb": {
"@id": "https://www.agespace.org/services/home-care/essex"
},
"inLanguage": "en-GB"
},
{
"@type": "BreadcrumbList",
"@id": "https://www.agespace.org/services/home-care/essex",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "https://www.agespace.org/"
},
{
"@type": "ListItem",
"position": 2,
"name": "Essex"
}
]
},
{
"@type": "WebSite",
"@id": "https://www.agespace.org/#website",
"url": "https://www.agespace.org/",
"name": "Age Space",
"description": "sharing advice on elderly care",
"potentialAction": [
{
"@type": "SearchAction",
"target": {
"@type": "EntryPoint",
"urlTemplate": "https://www.agespace.org/?s={search_term_string}"
},
"query-input": "required name=search_term_string"
}
],
"inLanguage": "en-GB"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment