Title: Link Query
Last modified: January 24, 2023

---

# Link Query

 *  [Basit](https://wordpress.org/support/users/basitbasit11333/)
 * (@basitbasit11333)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/link-query/)
 * Hi,
   I am using generatepress, I do blogging on it. You know when you are posting,
   outbound links becomes necessary.But when I was creating a outbound link and 
   set it it “open in new tab”, generatepress automatically make that link “noreferer
   noopener”.Any code you can give me to set it as “noopener only” plz.Thank you

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [fernandoazarcon2](https://wordpress.org/support/users/fernandoazarcon2/)
 * (@fernandoazarcon2)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/link-query/#post-16402138)
 * Hi [@basitbasit11333](https://wordpress.org/support/users/basitbasit11333/),
 * That’s controlled by WordPress. See: [https://github.com/WordPress/gutenberg/issues/26914](https://github.com/WordPress/gutenberg/issues/26914)
 * Perhaps you can try adding this snippet through a plugin like Code Snippets:
 *     ```wp-block-code
       add_filter( 'wp_targeted_link_rel', 'my_targeted_link_rel_remove_noreferrer' );
       function my_targeted_link_rel_remove_noreferrer( $rel_values ) {
       return preg_replace( '/noreferrer\s*/i', '', $rel_values );
       }
       ```
   
 *  [Sourav Pan](https://wordpress.org/support/users/microbiologynote/)
 * (@microbiologynote)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/link-query/#post-16402406)
 * You can use the wp_targeted_link_rel() filter to change the link rel attribute
   for outbound links in GeneratePress. Here’s an example of how you can use this
   filter to set the link rel attribute to “noopener only” for outbound links:
 *     ```wp-block-code
       function custom_link_rel( $rel, $link ) {
           if ( strpos( $link, '//' ) === 0 && strpos( $link, home_url() ) === false ) {
               $rel = 'noopener';
           }
           return $rel;
       }
       add_filter( 'wp_targeted_link_rel', 'custom_link_rel', 10, 2 );
       ```
   
 * You can add this code to your theme’s `functions.php` file, or you can use a 
   plugin like Code Snippets to add it.
 * The function first checks if the link is an outbound link using the `strpos()`
   function, which checks if the link starts with “//” and doesn’t contain the home
   URL. If the link is an outbound link, the function changes the link rel attribute
   to “noopener”.
 * It’s important to note that this filter only affects links that are added to 
   the post content, not the links that are added to the post meta or other places
   in the theme.
 * Also, “noopener” attribute is added to the link to prevent a newly opened tab
   from having access to the window.opener object, which can be used

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Link Query’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/generatepress/3.6.1/screenshot.
   png)
 * GeneratePress
 * [Support Threads](https://wordpress.org/support/theme/generatepress/)
 * [Active Topics](https://wordpress.org/support/theme/generatepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/generatepress/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/generatepress/reviews/)

 * 2 replies
 * 3 participants
 * Last reply from: [Sourav Pan](https://wordpress.org/support/users/microbiologynote/)
 * Last activity: [3 years, 4 months ago](https://wordpress.org/support/topic/link-query/#post-16402406)
 * Status: not resolved