Add More sameAs schema for author

#373536
  • Resolved Ross
    Rank Math free

    Hello,

    I dont know how to properly add more sameAs examples for author: https://ibb.co/dDhfzBC

    in this funtion

    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
    	return [];
    }, 99, 2);

    Can you help me?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Anas
    Rank Math business

    Hello,

    Thank you for contacting Rank Math.

    You can use this filter to add sameAs property:

    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
        if ( isset( $data['publisher'] ) ) {
            $data['publisher']['sameAs'] = ['https://twitter.com/RankMath', 'https://facebook.com/....'];
        }
        return $data;
    }, 99, 2 );

    Hope that helps.

    Thank you.

    Ross
    Rank Math free

    Hello again, that code works for organization but not for author. I would like to add sameAs just for author.

    Like in this image: https://ibb.co/dDhfzBC

    Thanks!

    Hello,

    Please refer to this filter code instead:

    add_filter( 'rank_math/snippet/rich_snippet_article_entity', function($entity) {
        if($entity['author']){
            $entity['author']['sameAs'] = [
                'https://twitter.com/RankMath',
                'https://facebook.com/...'
            ];
        }
    
        return $entity;
    });

    See if this helps you with your goal.

    Looking forward to helping you on this one.

    Ross
    Rank Math free

    Works! Thank you!

    Hello,

    We are super happy that this resolved your issue.

    If you have other issues/questions in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this ticket.