I got some problems using rank math SEO plugin, when I add links on posts and after publish I see rank math added class="rank-math-link" on every link.

<a href="//" class="rank-math-link">link text</a>

how can I remove that...?

  • I think you'd have to ask them. At first glance it looks like it's added by their Gutenberg code, and isn't used or styled elsewhere, so there ought not be any harm in removing it unless it breaks some block editor integration (e.g. if it adds some extra properties to a link if this is present?) But I don't know Gutenberg or this plugin well so I'm speculating.
    – Rup
    Apr 20, 2020 at 8:41
  • At a pinch you could write a post-save or post-update hook to remove these classes as you save the post to the DB. But I think it's better to ask Rank Math directly what these classes are for.
    – Rup
    Apr 20, 2020 at 8:42
  • I ask them but they didn't solve this. So I want to put some on theme functions for that. Apr 20, 2020 at 23:25

2 Answers 2


I found this very irritating. So, I came up with my own solution. This filters the content before it gets sent to the browser while leaving the stored version in the DB unchanged. I believe Rank Math needs the class for Gutenberg special link options. Win-win for both you and Rank Math.

if ( !function_exists('filter_the_content_remove_rank_math_link') ) {
     * Remove/filter `rank-math-link` class added by Rank Math
     * @param $content
     * @return string|string[]
    function filter_the_content_remove_rank_math_link( $content )
        // Check if we're inside the single Post.
        if ( is_singular() ) {
            $content = str_replace(['rank-math-link', 'class=""'], '', $content);

        return $content;

    add_filter('the_content', 'filter_the_content_remove_rank_math_link', 1);

Yes, you can also change the str_replace or used a regex


Rank math has function that will disable this.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.