Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save resonancedesigns/066b440314e1b993dd4b to your computer and use it in GitHub Desktop.
Save resonancedesigns/066b440314e1b993dd4b to your computer and use it in GitHub Desktop.
JSON LD using custom fields from wordpress.
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "SelfStorage",
"address": {
"@type": "PostalAddress",
"addressLocality": "<?php echo($location_town) ?>",
"addressRegion": "<?php echo($location_county) ?>",
"postalCode":"<?php echo($location_postcode) ?>",
"streetAddress": "<?php echo($location_address_line_1) ?>,
<?php
if (!empty($location_address_line_2)) {
echo''. $location_address_line_2 .', ';
}
if (!empty($location_address_line_3)) {
echo''. $location_address_line_3 .'';
}
?>"
},
"name": "<?php bloginfo('name'); ?>",
"telephone": "<?php echo main_branch('tel'); ?>",
<?php
if ($location_24h == true) {
echo '
"openingHours": [
"Mo 00:00-00:00",
"Tu 00:00-00:00",
"We 00:00-00:00",
"Th 00:00-00:00",
"Fr 00:00-00:00",
"Sa 00:00-00:00",
"Su 00:00-00:00"
]
';
} else {
if (!empty($location_openinh_hours)) {
echo'
"openingHours": [
"Mo '.$location_openinh_hours.'",
"Tu '.$location_openinh_hours.'",
"We '.$location_openinh_hours.'",
"Th '.$location_openinh_hours.'",
"Fr '.$location_openinh_hours.'",
"Sa '.$location_openinh_hours.'",
"Su '.$location_openinh_hours.'"
]
';
}
}
?>
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment