VPS参考、测评、推荐
分享你关注的VPS主机优惠信息

WordPress实现了博客文章标题到自定义URL的链接(WordPress添加链接)。

WordPress实现了博客文章标题到自定义URL的链接(WordPress添加链接)。

很多博主都遇到过将wordpress文章标题链接到用户自定义URL地址的需求。当点击文章链接时,不会直接文章详情页,而是直接共享链接的网页,就像微博一样。为了达到这个效果,你使用插件:链接到或者WP Post重定向,但是为这个小功能再安装一个插件就有点小题大做了。

WordPress实现了博客文章标题到自定义URL的链接(WordPress添加链接)。

模式1:

其实在文章中添加自定义字段,在主题的functions.php中添加以下🙁:网站根目录/wp-content/themes/主题名夹/functions.php)。

/** * WordPress文章标题链接到站外链接*/function link _ format _ URL($ link,$ post){ if(has _ post _ format(‘ link ‘,$ post)&;& ampget _ post _ meta($ post-& ,’ LinkFormatURL ‘,true)){ $ link = get _ post _ meta($ post-& ,’ LinkFormatURL ‘,true);} return $ link}add_filter(‘post_link ‘,’ link_format_url ‘,10,2);模式2:

依次打开wordpress背景外观/主题/模板功能(functions.php),添加以下代码:

/** * WordPress文章标题链接到站外链接*/function link _ format _ URL($ link,$ post){ if(has _ post _ format(‘ link ‘,$ post)&;& ampget _ post _ meta($ post-& gt;ID,’ LinkFormatURL ‘,true)){ $ link = get _ post _ meta($ post-& gt;ID,’ LinkFormatURL ‘,true);} return $ link}add_filter(‘post_link ‘,’ link_format_url ‘,10,2);使用教程:

新建一篇wordpress文章时,在文章末尾的自定义字段中选择名称:LinkFormaturl,取值:输入你希望文章标题的url地址,发布文章即可上述功能。

:WordPress实现了博客文章标题到自定义URL的链接(WordPress添加链接)。 https://vps.caogenba.com.com/110919.html

赞(0) 打赏
未经允许不得转载:草根吧VPS_最新VPS信息参考 » WordPress实现了博客文章标题到自定义URL的链接(WordPress添加链接)。
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址