Username / login exposed on meta text in source code at rank-math-schema class

#354548
  • Resolved Sigurd Greb
    Rank Math free

    Dear ladies and gentlemen,

    I just found out that in the source code the username / login is exposed by rankmath in the header section. I deleted the twitter labels where it was mentioned once by disabling all the slack filters. However, the username is still exposed in the rank math schema class.

    1) How to avoid the exposure of the login / username in the source code?
    2) How to get rid of the twitter labels since we are not using twitter at all

    Many thanks in advance for your efforts and kind regards
    Sigurd

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hello,

    Thank you for contacting the support, and sorry for any inconvenience that might have been caused due to that.

    1) Can you please confirm if you are referring to your author in under the schema structure?

    The author is a required part of the article schema which is usually taken from the settings of the user who publishes the post. The URL you shared is a blog page whose schema is generated from the posts on the blog.

    You can check out these google document on structured data types: https://developers.google.com/search/docs/data-types/article

    However, if you wish to proceed with removing the author, you may need to use a filter to remove the author schema. Please refer to the code below and insert it into your theme’s functions.php file:

    /**
     * Filter to change the schema data.
     * Replace $schema_type with schema name like article, review, etc.
     *
     * @param array $entity Snippet Data
     *
     * @return array
     */
    add_filter( "rank_math/snippet/rich_snippet_{$schema_type}_entity", function ( $entity ) {
    	if ( isset( $entity['author'] ) ) {
    		unset( $entity['author'] );
    
    		return $entity;
    	}
    
    	return $entity;
    } );

    Please note you need to change the {$schema_type} to the object type you wish to modify.

    2) Please clear your website and browser cache after applying the filter and check the frontend again. If the issue persists, please share your website URL here.

    Looking forward to helping you

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Prabhat
    Rank Math agency

    Hello,

    1. I checked the source of your website and was able to find the author (shlo********ig10) in the schema but not in the meta tags. Could you share a screenshot of the meta tag you’re referring to? You can use a tool like imgur.com to upload the screenshot and share the link/URL of the screenshot here in the ticket.

    2. To remove the Twitter label tags, please add the bellow code to the website:

    /**
     * Hook to remove og:tags
     */
    add_action( 'rank_math/head', function() {
    	remove_all_actions( 'rank_math/opengraph/slack' );
    });

    You can also follow this guide to add the filter to the website:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Looking forward to hearing back from you.

    Thank you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Prabhat
    Rank Math agency

    Hello,

    Please replace the code shared by my colleague with the below one and see if it removes the author from the schema section:

    add_filter( 'rank_math/json_ld', function( $entities, $jsonld ) {
        if ( isset( $entities['ProfilePage'] ) ) {
            $id = $entities['ProfilePage']['@id'];
            foreach ( $entities as $key => $entity ) {
                if ( isset( $entity['author' ]['@id'] ) && $id === $entity['author' ]['@id'] ) {
                    unset( $entities[ $key ]['author'] );
                }
            }
            unset( $entities['ProfilePage'] );
        }
        return $entities;
    }, 999, 2 );

    In the second screenshot you shared, a <span> tag is added with the author’s name. It doesn’t seem like it is getting added by Rank Math. However, I was unable to find it on the homepage. Could you exactly point us to where (on which page) is this tag located?

    Looking forward to hearing back from you.

    Thank you.

    Hi,

    I don´t exactly understand now which code to insert via code snippet?
    1) Remove twitter author
    2) Remove Schema author

    Please advise.

    Many thanks and kind regards
    Sigurd

    Prabhat
    Rank Math agency

    Hello,

    Both the snippets provided are for your different concerns and you can add them both.

    Hope this helps.

    Thank you.

    The one you have sent or the one Jeremy wrote? I am a bit confused

    Prabhat
    Rank Math agency

    Hello,

    You can add both the codes I shared in my replies.

    Hope this helps.

    Thank you.

    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 9 replies - 1 through 9 (of 9 total)

The ticket ‘Username / login exposed on meta text in source code at rank-math-schema class’ is closed to new replies.