How to remove comments in the schema for the homepage?

#14001
  • Resolved Poor Swiss
    Rank Math free

    Hi,

    On my blog (https://thepoorswiss.com), the homepage has a ton of comments in the schema.

    For instance:
    {"@type":"Comment","dateCreated":"2019-08-16 14:09:59","description":"Thanks for including my tip! I've saved tons of money by shopping around at subscription renewal time every year and I always tell my friends to haggle!\r\n\r\nLove the other tips too - one of my favourites is drinking tap water. I am a big fan of tap water and am shocked when people still buy bottled water which probably came from the same place as the tap water!","author":{"@type":"Person","name":"Peter @ CountingEveryDollar","url":"https:\/\/CountingEveryDollar.com"}}],"wordCount":113}

    How can I get rid of that?

    Thanks

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

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

    Can you confirm that you share the right website link? I cannot seem to spot the type of schema mentioned on the page source which is a bit odd.
    You can however remove a particular schema type if it was added by Rank Math by making use of the following filter to unset the type in your functions.php file:

    /**
     * Filter to Short-circuit Schema if a 3rd party is interested in generating their own data.
     * Replace $schmea_type with schema name like article, review, etc.
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( "rank_math/snippet/rich_snippet_{$schema_type}", function( $entity ) {
     return $entity;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Hi,

    I removed the comments by editing the code of the plugin myself.

    If I understand correctly, the code you gave me will entirely disable one schema, right? I just want to remove the comments parts from the homepage schema.

    Thanks

    Hi there,

    Thanks for the follow up.

    It is not recommended to edit plugin code directly since the changes will definitely get lost once you update the plugin.
    Please use this filter to modify a certain schema type and remove some properties that you do not wish to be present.
    Here is an example to unset one of the properties:

    add_filter( 'rank_math/snippet/rich_snippet_review_entity', function( $entity ) {
    	
    	unset($entity['dateModified']);
    	return $entity;
    }, 10, 1 );

    I hope this info helps. Thank you.

    Alright, I removed the changes on the code. The comments are present in my home page again.

    I tried this:

    function cleanup_blog_schema($entity){
    	unset($entity['commentCount']);
    	unset($entity['comment']);
    	
    	return $entity;
    }
    
    add_filter( 'rank_math/snippet/rich_snippet_blog_posting', 'cleanup_blog_schema', 10, 1 );

    But it didn’t work. I also tried with blog schema directly and unsetting elements in the blogPost but it did not work either.

    Thanks a lot for your support!

    • This reply was modified 4 years, 7 months ago by Poor Swiss.

    Hi there,

    Thanks for the follow up.

    The rich snippet type is “Article” and thus you should modify the filter to the following:

    function cleanup_blog_schema($entity){
    	unset($entity['commentCount']);
    	unset($entity['comment']);
    	
    	return $entity;
    }
    
    add_filter( 'rank_math/snippet/rich_snippet_article_entity', 'cleanup_blog_schema', 10, 1 );

    Let us know how this goes. Thank you.

    I just tried this code, but it didn’t change anything 🙁

    Hello there,

    Apologies for the huge delay.

    We might need to take a closer look at the settings. Please edit the first post on this ticket and include your WP logins in the designated Sensitive Data section.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Sorry, but I don’t give access to my site.

    I entirely disabled the Blog schema, this is much easier.

    add_filter( 'rank_math/json_ld/blog_enabled', '__return_false' );

    • This reply was modified 4 years, 7 months ago by Poor Swiss.

    Hi there,

    Thanks for the follow up.

    I am gad that this is now resolved 🙂

    Feel free to contact us for any other questions, comments or suggestions. 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 ‘How to remove comments in the schema for the homepage?’ is closed to new replies.