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.

1 Answer 1


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
    Commented Dec 16, 2018 at 13:57
  • 1
    Well, but this is an exclusively WordPress related stack...
    – cjbj
    Commented Dec 16, 2018 at 14:02
  • I know, but the question was moved from SuperUser to WordPress stack.
    – Mentalhead
    Commented Dec 17, 2018 at 6:14
  • @Mentalhead it is IMHO wordpress related as you desscribe the ends is to have target=_blank in your wordpress. As suggested by cjbj it is wise to add this filter, as you don't have to finally worry how you paste the links into wordpress, as wordpress would do the correction if needed. Think about it that way: if the mountain won't come to the prophet, the prophet must go to the mountain. Commented Jul 18, 2023 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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