ProfilePage Structured Data for Team Members
Adds ProfilePage JSON-LD with a Person (name, job title, photo and LinkedIn) to each team member page, linking staff to your organization.
Opens WPIDE on
Code
add_action( 'wp_head', function () {
if ( ! is_singular( 'team' ) ) {
return;
}
$post = get_queried_object();
$person = array(
'@type' => 'Person',
'name' => wp_strip_all_tags( get_the_title( $post ) ),
'jobTitle' => (string) get_post_meta( $post->ID, '_team_role', true ),
'image' => get_the_post_thumbnail_url( $post, 'large' ),
'url' => get_permalink( $post ),
'sameAs' => array_values( array_filter( array( (string) get_post_meta( $post->ID, '_team_linkedin', true ) ) ) ),
'worksFor' => array( '@type' => 'Organization', 'name' => get_bloginfo( 'name' ), 'url' => home_url( '/' ) ),
);
$data = array(
'@context' => 'https://schema.org',
'@type' => 'ProfilePage',
'dateModified' => get_the_modified_date( DATE_W3C, $post ),
'mainEntity' => array_filter( $person ),
);
echo '<script type="application/ld+json">' . wp_json_encode( $data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_HEX_TAG ) . "</script>\n";
} );
Notes
Reads the Team Member Details meta box fields. Email and phone are left out on purpose.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.