admin管理员组文章数量:1136619
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 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...?
Share Improve this question asked Apr 20, 2020 at 8:21 Jenny DearbornJenny Dearborn 1 3- 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 Commented 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 Commented 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. – Jenny Dearborn Commented Apr 20, 2020 at 23:25
2 Answers
Reset to default 0I 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.
https://rankmath.com/kb/filters-hooks-api-developer/#remove-rank-math-link-class
本文标签: themesi want remove class from post links
版权声明:本文标题:themes - i want remove class from post links 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736842460a1955160.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论