Schema.org sameAs property for linkedin , facebook ,

  • The Schema.org item organization contains a property called sameAs.
    This is a good place to list your accounts such as Instagram, Facebook, Twitter according to some SEO analysis tool.
    Can we use Rank Math to create this part of the Structured-Data ?

    <script type="application/ld+json">
      {
        "@context": "http://schema.org",
        "@type": "Organization",
        "name": "HejazUltra",
        "url": "https://HejazUltra.org",
        "address": "Jeddah, Saudi Arabia",
        "sameAs": [
          "https://www.facebook.com/groups/HejazUltra",
          "https://twitter.com/hejazultra",
          "https://www.linkedin.com/company/hejaz-ultra"
        ]
      }
    </script>
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    A few days ago I published a code that I think you might find useful, you can modify that part of the Schema using this filter, and for example, in this snippet I am adding new URLs to the ‘sameAs’ field, but you could modify everything:

    /**
    * Collect data to output in JSON-LD.
    *
    * @param array $unsigned An array of data to output in json-ld.
    * @param JsonLD $unsigned JsonLD instance.
    */
    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
    	$currentSameAs = $data['Organization']['sameAs'];
            $currentSameAs[] = "https://wordpress url....";
            $currentSameAs[] = "https://blogger url....";
            $currentSameAs[] = "https://tumblr url....";
            // And so on...
    
            $data['Organization']['sameAs'] = $currentSameAs;
    	return $data;
    }, 10, 2);

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Hello,

    Thank you for the follow up.

    I have tested the following code and it is working on my end. Please try it and let us know:

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

    Looking forward to helping you. Thank you.

    ​​​​​​

    Hello Michael,

    Thanks a bunch… this WORKED!

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question 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 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this ticket.