Filter social profiles in Schema.org

Need help with this?
Purchase All in One SEO Pack Pro to get dedicated support from us.

Buy Now

By default, All in One SEO Pack only has fields for Facebook and Twitter profiles on the Edit User screen.  This filter can be used to add more social profiles for output in our Schema.org markup for Author on Posts.

function aioseop_schema_add_social_profiles( $data ) {
     if ( is_single() ) {
          global $post;
          $post_author_nicename = get_the_author_meta( 'user_nicename', $post->post_author );

          $users_social = array(
               // Replace nicename with the user's nicename.
              'nicename' => array(
                   // Replace with user's social profile links adding lines for each social network.
                   'https://www.linkedin.com/in/myprofile',
                   'https://www.instagram.com/myprofile',
              ),
          );

          // This will add the social profile links to a matched user.
          if ( isset( $users_social[ $post_author_nicename ] ) ) {
               $data['sameAs'] = array_merge( $data['sameAs'], $users_social[ $post_author_nicename ] );
          }
     }

     return $data;
}
add_filter( 'aioseop_schema_class_data_AIOSEOP_Graph_Person', 'aioseop_schema_add_social_profiles' );

For instructions on how to use this code, please refer to our FAQ here.

  • Was this helpful ?
  • YesNo