Add “Same As” Schema for Other Properties Error

#129623
  • Resolved Dennis k
    Rank Math free

    Hello i did found a code here from a previous ticket Ticket url but the code is throwing syntax error on the last line (} 10,2); `/**
    * 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 ) {
    if(is_singular(‘listing’)){
    $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);`

    Can you help me i have tried several fixes but isn’t working.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Danial
    Rank Math business

    Hello,

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

    You need to change the URL to your website in $currentSameAs[] = “your url”

    I hope this helps resolve your issue.

    Any help

    Danial
    Rank Math business

    Hello,

    Change the URLs on here to your own URLs:
    https://wordpress url.... , https://blogger url...., https://tumblr url....

    And the location for you to put this is at the bottom of your functions.php

    I hope this helps resolve your issue and let me know if there is anything else.

    Hello,

    Please note that we removed the Social Meta options for “sameAs” Schema intentionally because Google/Yandex doesn’t use it anymore. It is like the keyword meta tags that many webmasters spend extra time on but it is also ignored by Google and there is zero advantage of having the sameAs code just like there is zero advantage if you have the meta keywords on your website.

    Google has changed a lot and they get more intelligent every passing minute with AI and countless algorithms they have in place. They pick the Social profiles from across the web and they do not need you to have the “sameAs” tag to show the social profiles in your Knowledge Panel.

    Here is an example you can confirm from your end as well.

    If you search for “Walmart”, these are all the social profiles you see:

    walmart knowledgebase

    Go to their website and you will notice that they don’t have a single “sameAs” tag:

    no sameAs schema

    You can run it through the Google Rich Results test as well and notice they don’t have any Schema for those social profiles:

    social profiles

    As you can see, the social profiles are shown in the knowledge panel not because you have the “sameAs” code, but rather because you are an established brand with a strong social media presence.

    This is why we removed the “sameAs” tags in Rank Math and here are links from Google and Bing that essentially tell you that having sameAs tags doesn’t affect the addition or removal of social profiles from your knowledge panel:
    https://support.google.com/knowledgepanel/answer/7534842
    google's statement from the above link
    &
    https://www.bing.com/webmaster/help/markup-businesses-and-organizations-cc507c09

    If you still want to add it, then you can use the filter as follows by adding it to your theme’s functions.php or by using a plugin like Code Snippets:

    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 and please do not hesitate to let us know if you need our assistance with anything else.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

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

The ticket ‘Add “Same As” Schema for Other Properties Error’ is closed to new replies.