Forked from nicomollet/wpseo_schema_organization.php
Created
September 10, 2019 14:14
-
-
Save ulziibat-n/ce6e9225f1a83800f27b01c1b7c00ccb to your computer and use it in GitHub Desktop.
Yoast SEO Organization Schema Replaced By LocalBusiness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add LocalBusiness to schema Organization | |
* | |
* @api array $data The graph piece to filter. | |
* | |
* @return array | |
*/ | |
function custom_wpseo_schema_organization($data){ | |
$data['address'] = [ | |
'@type' => 'PostalAddress', | |
'streetAddress' => 'My address', | |
'postalCode' => 'My postal code', | |
'addressLocality' => 'City', | |
'telephone' => '0123456789', | |
]; | |
$data['@type'] = 'LocalBusiness'; | |
$data['telephone'] = '0123456789'; | |
$data['image'] = 'pathtoimage'; | |
$data['priceRange'] = '$$'; | |
return $data; | |
} | |
add_filter('wpseo_schema_organization', 'custom_wpseo_schema_organization', 10, 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ulziibat-n any idea how to insert sepcific pieces in specific places via the dev API? At the moment I've only managed to insert it in the end of the organization for example.
Would like to inject some more fields after the already generated name and more sameAS fields.
The only solution I've found is to hard code the
@graph
and no longer rely on the dynamic and wp parts of yoast. Or add them in the end. But it doesn't look ideal to have sameAS urls spread around and not after each other. And same with the mixed order.Any idea or solution you've found as you've played with the API more than me?