I'm unable to set Word hyperlinks to open in a new window/tab. Basically, I create a Word document and paste its contents to WordPress, and everything is there, links do work, but they don't have "target=_blank" attribute added to them.

I do set Target Frame option in Word, but nothing happens. I've tried using _blank and New Window values, but when looking at code the target attribute isn't added.

I tried using Ctrl + F9 trick to force my links to open in new window, but that doesn't work.

Is there a way to fix that?

EDIT: This is a Word-related issue. I'm not developing a WordPress theme, I just want to paste the text from Word into WordPress and have my links open in new window. This works perfectly with Libre Office, but not with Microsoft Office.


The solution for this would be to build a filter on the_content that scans the pasted text for links and adds target="_blank". Actually, you don't even have to build it yourself, because WP has a built in function to do this. All you have to do is add this line to the functions.php of your theme:

add_filter ('the_content','links_add_target');

Beware that if your theme is updated your functions.php will be replaced and your edit lost. The correct way to circumvent this would be to build a child theme.

  • I appreciate the replay, but this isn't Wordpress related issue. I'm not developing a theme, I just want to open my hyperlinks in new window/tab. This is exclusively a Word-related issue. – Mentalhead Dec 16 '18 at 13:57
  • 1
    Well, but this is an exclusively WordPress related stack... – cjbj Dec 16 '18 at 14:02
  • I know, but the question was moved from SuperUser to WordPress stack. – Mentalhead Dec 17 '18 at 6:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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