wordpress外部访问_如何使用WordPress在新窗口或选项卡中打开外部链接

wordpress外部访问

Do you want to open external links from your blog posts in a new window?

您是否要在新窗口中打开博客文章的外部链接?

Opening external links in a new window allows your users to visit the link without leaving your website.

在新窗口中打开外部链接可让您的用户访问链接而无需离开您的网站。

Many beginners struggle with finding the option to open a link in a window mainly because it is not instantly visible when you are adding a link in WordPress.

许多初学者很难找到在窗口中打开链接的选项,主要是因为在WordPress中添加链接时该链接不会立即显示。

In this beginner’s guide, we will show how to easily open external links in a new window on your WordPress site. We will also show different methods to do that, so you can choose the one that best suits you.

在此初学者指南中,我们将展示如何在WordPress网站上的新窗口中轻松打开外部链接。 我们还将展示执行此操作的不同方法,因此您可以选择最适合自己的一种。

How to open external links in a new window
为什么以及何时应该在新窗口中打开外部链接? (Why and When You Should Open External Links in a New Window?)

External links are links to websites that you don’t own or control. Normally, if you add a link to an external website your visitors will simply leave your site by clicking on the link.

外部链接是指向您不拥有或控制的网站的链接。 通常,如果您添加到外部网站的链接,访问者只需单击链接即可离开您的网站。

While some user experience experts say that you should not open external links in a new window, we do not agree with that.

尽管一些用户体验专家说您不应在新窗口中打开外部链接,但我们不同意。

You see, most users easily forget the last website they were visiting. If they have multiple tabs open then chances are that they will never be able to find your website again.

您会看到,大多数用户很容易忘记他们访问的最后一个网站。 如果他们打开了多个标签,则他们将永远无法再次找到您的网站。

For better user experience, we recommend opening external links in a new window or tab. This way the original web page is not lost and users can resume browsing your website by switching back.

为了获得更好的用户体验,我们建议在新窗口或标签中打开外部链接。 这样,原始网页就不会丢失,用户可以通过切换回去继续浏览您的网站。

Another benefit of opening external links in a new window is increased page views and user engagement on your site. Users are more likely to return to the previous tab and finish reading the article.

在新窗口中打开外部链接的另一个好处是增加页面浏览量和网站上的用户参与度 。 用户更有可能返回上一个标签并完成阅读文章。

Users who spend more time on your site are more likely to join your email newsletter, follow you on social media, leave a comment, and buy your products.

在您的网站上花费更多时间的用户更有可能加入您的电子邮件通讯 ,在社交媒体上关注您,发表评论并购买产品。

That being said, let’s take a look at how to easily open external links in a new Window in WordPress.

话虽如此,让我们看一下如何轻松地在WordPress的新窗口中打开外部链接。

在Gutenberg编辑器中的新窗口中打开外部链接 (Open External Link in New Window in Gutenberg Editor)

The new WordPress block editor has a built-in feature that lets you open external links in a new window. However the option is hidden behind a button which is why beginners often don’t notice it.

新的WordPress块编辑器具有内置功能,可让您在新窗口中打开外部链接。 但是,该选项隐藏在按钮后面,因此初学者通常不会注意到它。

Simply edit a blog post or page where you want to add an external link. Next, select the text you want to link and then click on the insert link button (or press CTRL + K on Windows / Command + K on Mac).

只需编辑您要在其中添加外部链接的博客文章或页面。 接下来,选择要链接的文本,然后单击插入链接按钮(或在Windows上按CTRL + K /在Mac上按Command + K)。

Open link in new tab

This will bring up the insert link popup. Simply enter the link and then click on the down arrow next to it. This will reveal the option to open the link new tab.

这将弹出插入链接弹出窗口。 只需输入链接,然后单击它旁边的向下箭头。 这将显示打开链接新选项卡的选项。

Click to toggle the option and then press enter. Your selected text will now be linked, and you can preview it by visiting your website.

单击以切换选项,然后按Enter。 您选择的文本现在将被链接,您可以通过访问您的网站进行预览。

使用经典编辑器在新窗口中打开外部链接 (Open External Link in a New Window Using Classic Editor)

WordPress introduced a new block editor with WordPress 5.0. Many users prefer to use the old editor by installing the classic editor plugin.

WordPress在WordPress 5.0中引入了新的块编辑器 。 许多用户喜欢通过安装经典编辑器插件来使用旧的编辑

If you are still using classic editor, then we will recommend you to start using the new editor. It is modern, faster, and includes many new features that you are missing out.

如果您仍在使用经典编辑器,那么我们建议您开始使用新的编辑器。 它是现代的,速度更快的,并且包含许多您遗漏的新功能。

However, if you still want to use the classic editor, then this is how you would open a link in a new window using the classic editor.

但是,如果仍要使用经典编辑器,则可以使用经典编辑器在新窗口中打开链接。

First, you need to edit the post or page where you want to add the link. Next, select the text that you want to link and then click on the add link button.

首先,您需要编辑要在其中添加链接的帖子或页面。 接下来,选择要链接的文本,然后单击“添加链接”按钮。

Add new link in classic editor

A popup would appear where you can add your external link. After that, click on the gear icon next to it. This will bring up the advanced insert link popup.

将会出现一个弹出窗口,您可以在其中添加外部链接。 之后,点击其旁边的齿轮图标。 这将弹出高级插入链接弹出窗口。

Open link in new tab using the classic editor

From here you need to check the box next to ‘Open link in a new tab’ checkbox and then click on the ‘Update’ button to add your link.

在这里,您需要选中“在新标签页中打开链接”复选框旁边的复选框,然后单击“更新”按钮以添加您的链接。

You can now save your post and preview it to see the link in action.

现在,您可以保存您的帖子并对其进行预览,以查看链接的作用。

在经典编辑器中使用“文本”选项卡在“新建”选项卡中打开链接 (Open a Link in New Tab Using Text Tab in Classic Editor)

If you are using the HTML editor labeled ‘Text‘ in the old classic editor, then here is how you would open an external link in a new window.

如果您在旧的经典编辑器中使用的是标记为“ 文本 ”HTML编辑器,那么您将在新窗口中打开外部链接。

Add link button in the Text editor

Simply select the text that you want to link and then click on the Add Link button. This will bring up the advanced Insert link popup.

只需选择要链接的文本,然后单击“添加链接”按钮。 这将弹出高级“插入”链接弹出窗口。

Adding a link in plain text editor using the classic editor

From here, you can add the link and check the box next to ‘Open link in new tab’ option. After that click on the Add Link button and the popup will disappear. You will now see the HTML code for the link in the text editor.

在这里,您可以添加链接并选中“在新标签页中打开链接”选项旁边的框。 之后,单击“添加链接”按钮,弹出窗口将消失。 现在,您将在文本编辑器中看到链接HTML代码。

HTML code for the external link

You can now save your changes and view the post to see the external link in action.

现在,您可以保存更改并查看帖子,以查看正在使用的外部链接。

如何使用HTML在新窗口中打开外部链接 (How to Open External Links in a New Window using HTML)

Sometimes you may need to write HTML to add a link in WordPress. For example, when you are using the HTML mode in the new block editor or adding a link in a WordPress theme template file.

有时您可能需要编写HTML才能在WordPress中添加链接。 例如,当您在新的块编辑器中使用HTML模式或在WordPress主题模板文件中添加链接时。

You’ll need to add the link using the following HTML code.

您需要使用以下HTML代码添加链接。


<a href="http://example.com" target="_blank" rel="noopener">Link Text</a> 

Simply replace the example.com with the external link URL, and the Link Text with the text you want to link.

只需将example.com替换为外部链接URL,并将“链接文本”替换为您要链接的文本。

The target parameter in this code tells browsers to open the link in a new window or tab.

此代码中的目标参数告诉浏览器在新窗口或标签中打开链接。

使用WordPress插件在新窗口中自动打开所有外部链接 (Automatically Open All External Links in New Window with a WordPress Plugin)

It may sound like extra work to manually check the option for every external link that you add. However, over time you will get used to it.

手动检查您添加的每个外部链接的选项似乎都需要额外的工作。 但是,随着时间的流逝,您会习惯它。

If you run a multi-author blog or often forget to make external links open in a new tab, then you can use a plugin for that.

如果您运行多作者博客或经常忘记在新标签中打开外部链接,则可以使用插件。

First, you need to install and activate the Open External Links in a New Window plugin. For more details, see our step by step guide on how to install a WordPress plugin.

首先,您需要在新窗口插件中安装并激活“ 打开外部链接” 。 有关更多详细信息,请参阅有关如何安装WordPress插件的分步指南。

The plugin works out of the box, and it will automatically open external links in a new window.

该插件开箱即用,它将在新窗口中自动打开外部链接。

It does not actually change the external links in your blog posts. Instead, it uses JavaScript to open external links in a new window.

它实际上并不会更改博客文章中的外部链接。 相反,它使用JavaScript在新窗口中打开外部链接。

Note: Keep in mind that deactivating the plugin will stop opening external links in a new window.

注意:请记住,停用插件将停止在新窗口中打开外部链接。

We hope this article helped you learn how to easily open external links in a new window in WordPress. You may also want to see our ultimate list of the most useful WordPress tips, tricks, and hacks that you can use on your website.

我们希望本文能帮助您学习如何在WordPress的新窗口中轻松打开外部链接。 您可能还想查看我们可以在您的网站上使用的最有用的WordPress技巧,窍门和黑客的最终列表。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/plugins/how-to-open-external-links-in-a-new-window-in-wordpress/

wordpress外部访问

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值