Modify Schema Pro Author Value for Articles Schema

Schema Pro allows us to set a custom value to the Author schema when we’re working with Article type Schemas, unfortunately it doesn’t allow us to have complete functionality over what can go in there -or even have multiple values-, the following snippet will let you do that:

function josueochoa_wp_schema_pro_article( $schema, $data, $post  ) {
     if( is_singular( 'post' ) ) {
         $post_id = get_the_ID();
         if( has_term( "", "post_author", $post_id ) ) { 
             $schema['author'] = array();
             foreach ( get_the_terms( $post_id, "post_author" ) as $author ) { 
                 $author_id = $author->term_id;
                 $schema['author'][] = array(
                     "@type" => "Person",
                     "name" => get_term_field( 'name', $author_id )
                 );
             }
         }
     }
     return $schema;
 }
 add_filter( 'wp_schema_pro_schema_article', 'josueochoa_wp_schema_pro_article', 10, 3 );

In the example above we’re assuming you want to replace the Author default schema with a custom value like a custom taxonomy (post_author).

Change article in wp_schema_pro_schema_article with the Schema type you’re working with.