I’m trying to remove author name from schema

#250904
  • Resolved Ahmed Sa’eed
    Rank Math free

    Hello, Auther username is showing in the schema and i’m not able to remove or change it after i changed the username
    “author”:{“@type”:”Person”,”name”:”xxx”}

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

    Thank you for contacting Rank Math and bringing your concern to our attention.

    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.

    If you require any further assistance don’t hesitate to get in touch. Thanks

    Sorry, how to find the object type?

    i did it like this but didn’t work

    
    /**
     * 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_{Article}_entity", function ( $entity ) {
    	if ( isset( $entity['author'] ) ) {
    		unset( $entity['author'] );
    
    		return $entity;
    	}
    
    	return $entity;
    } );
    

    Hello,

    Please replace the {$schema_type} to article to make it work. The filter should look like this:

    add_filter( "rank_math/snippet/rich_snippet_article_entity", function ( $entity ) {
    	if ( isset( $entity['author'] ) ) {
    		unset( $entity['author'] );
    		return $entity;
    	}
    	return $entity;
    });

    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 ‘I’m trying to remove author name from schema’ is closed to new replies.