Make WordPress Core

Opened 5 years ago

Closed 4 years ago

#47202 closed defect (bug) (reported-upstream)

Gutenberg doesn't honor the wp_targeted_link_rel Filter

Reported by: fabeyg's profile fabeyg Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Editor Keywords:
Focuses: Cc:


There is some inconsistent behaviour in how Gutenberg honors the wp_targeted_link_rel Filter.

In my filter I outpout just "noopener" instead of "noreferrer noopener" for the rel attribute Links that oben in a new tab/window:

function filter_save_link_rel ( $rel, $link ) {
  return 'noopener';
add_filter( 'wp_targeted_link_rel', 'filter_save_link_rel', 10, 2 );

When I write a new Link in a Gutenberg Paragraph Block the Editor automatically adds the rel="noopener noreferrer" attribute to the link.

However, when I remove the rel attribute in the HTML Block Editing Mode, the attribute is replaced with the correct value according to the filter.

Here is a screenshot of a fresh WordPress install displaying this behaviour:

Attachments (1)

screenshot_rel-attr.jpg (31.4 KB) - added by fabeyg 5 years ago.

Download all attachments as: .zip

Change History (5)

5 years ago


#1 @starvoters1
5 years ago

I am having the same issue on both classic editor and Gutenberg and ended up coding a workaround to remove "noreferrer", would be great if this filter could be fixed so we can just use this instead.

Editing to add, actually if I change the priority to 999, and remove the # of args setting it seems to be working fine on both Gutenberg and Classic, not sure of the priority needed. It may depend on theme and plugins installed too.

function filter_save_link_rel ( $rel, $link ) {
  return 'noopener';
add_filter( 'wp_targeted_link_rel', 'filter_save_link_rel', 999 );
Last edited 5 years ago by starvoters1 (previous) (diff)

This ticket was mentioned in Slack in #core by desrosj. View the logs.

5 years ago

#3 @wpwebdevj
4 years ago

Is there any update on this? I am having the same problem. I even tried installing WordPress 5.6 beta (which has removed noreferrer from wp_targeted_link_rel) but Gutenberg is still adding it.

#4 @SergeyBiryukov
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to reported-upstream
  • Status changed from new to closed

Hi there, welcome to WordPress Trac! Thanks for the report.

Please note that any issues for the block editor are tracked on GitHub:

Looks like there is already a Gutenberg issue for this:, so I'm closing the ticket as reported-upstream.

Note: See TracTickets for help on using tickets.