Remove Rankmath default schema

#519226
  • Resolved gantest
    Rank Math free

    I imported my own schema through the json custom code and would like to use just them, but noticed Rankmath is also adding some default schema (organization, webpage and etc.)
    How can I remove Rankmath’s default schema and just use mine?

    Thank you

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

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

    You can try to use the following filter to remove the Organization and Webpage schema from your website:

    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
         unset($data['publisher']);
         unset($data['WebPage']); 
         return $data;
    }, 99, 2);
    

    But if you want to remove all the schema added by Rank Math, then please try the following filter. It will remove the all Rank Math schema from your website:

    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
         return [];
    }, 99, 2);
    

    Here is a guide you can follow to add this filter:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Let us know how it goes.

    Thank you.

    ​​​​​​​

    gantest
    Rank Math free

    Hey, thanks for the quick response, it worked however the code

    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
         return [];
    }, 99, 2);

    removes all the schema – even the custom one I imported.

    And this code:

    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
         unset($data['publisher']);
         unset($data['WebPage']); 
         return $data;
    }, 99, 2);

    did the job, however didn’t remove all. I added:

    unset($data['WebSite']); 
    unset($data['place']);

    but whats the syntax for removing ImageObject as well?

    Thanks

    Hello,

    In this case, you can add the unset($data['ImageObject']) to remove the image Schema from your website:

    add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
         unset($data['publisher']);
         unset($data['WebPage']); 
         unset($data['WebSite']);
         unset($data['ImageObject']);
         return $data;
    }, 99, 2);
    

    Hope that helps and please don’t hesitate to let us know if you have any other questions.

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

The ticket ‘Remove Rankmath default schema’ is closed to new replies.