Hello,
Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.
Those “noopener” tags seems to be inside your FAQ Block, could you try to edit it and remove those tags in your links to see if the issue is solved?
Looking forward to helping you. Thank you.
Hi Alberto,
Thanks for your response.
Those tags are indeed inside FAQ block .
Since i have added codes to functions.php file to remove those tags , and it works , all of those tags were removed both from Block Editor and Classic Editor, but not works in FAQ Block.
The codes I added as below:
//This code prevents noreferrer from being added to new or updated posts
function im_targeted_link_rel($rel_values) {
return 'noopener';
}
add_filter('wp_targeted_link_rel', 'im_targeted_link_rel',999);
and this:
//remove noreferrer from existing links on the frontend (they may still show in the post editor)
function im_formatter($content) {
$replace = array("noreferrer " => "" ," noreferrer" => "");
$new_content = strtr($content, $replace);
return $new_content;
}
add_filter('the_content', 'im_formatter', 999);
I have no idea why those codes not work with FAQ blocks , since tags in other blocks are all removed.
Or whether you can provide other codes to remove those tags from FAQ block?
Hello,
Please use following code to remove noreferrer attribute from the FAQ schema data:
add_filter( 'rank_math/schema/block/faq-block', function( $data, $block ) {
if ( empty( $data['faqs'] ) ) {
return $data;
}
if ( ! empty( $data['faqs']['mainEntity'] ) ) {
foreach( $data['faqs']['mainEntity'] as $key => $entity ) {
$data['faqs']['mainEntity'][ $key ]['acceptedAnswer']['text'] = strtr( $entity['acceptedAnswer']['text'], [ "noreferrer " => "" ," noreferrer" => "" ] );
}
}
return $data;
}, 11, 2 );
I hope that helps.
Hi Pratik,
Thanks for your codes,I’ve added them to functions.php file , and it works on some pages , but still few pages has not been effected.
Will those codes works on whole site?
There are several pages (I’ve put them in sensitive data) which still have noreferrer tags in FAQ block that have not been removed by those code you provided.
And another question is : If I added that codes you provided with Code Snippets plugin, which method should I select? Run snippet everywhere or Only run on site front-end ?
-
This reply was modified 4 years, 3 months ago by Unbosomjam.
Hello,
The noreferrer tag you see on other pages are from the HowTo Block. To remove it from there, please add following code to your theme’s functions.php file:
add_filter( 'rank_math/schema/block/howto-block', function( $data, $block ) {
if ( empty( $data['howto'] ) ) {
return $data;
}
$data['howto']['description'] = strtr( $data['howto']['description'], [ "noreferrer " => "" ," noreferrer" => "" ] );
if ( ! empty( $data['howto']['step'] ) ) {
foreach( $data['howto']['step'] as $key => $entity ) {
$data['howto']['step'][ $key ]['itemListElement'][0]['text'] = strtr( $data['howto']['step'][ $key ]['itemListElement'][0]['text'], [ "noreferrer " => "" ," noreferrer" => "" ] );
}
}
return $data;
}, 11, 2 );
And you can run this code snippet only on frontend.
I hope that helps.
Hi Pratik
Thank you very much.
It works!!!
Those noreferrer tags in FAQ and HowTo blocks have been removed.
After this,I have a further question:
I am very satisfied with how the FAQ and HowTo schema appear in the Google search results.
They bring me a great SEO experience.
So I want to confirm:
Will those codes added to remove noreferrer tag make any difference to the implementation of the FAQ and HowTo Schema,especially to Google Structured Data Testing Tool?
Hello,
If you ask in terms of SEO and ranking on Google, no, they don’t. You can enter whatever content you want in those snippets, that meanwhile the content is useful for the users, it won’t affect your rankings, you don’t have to worry about it.
Looking forward to help 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.