通常情况下,在WordPress后台编辑文章的时候,直接粘贴网址到文章内容中,WordPress 并不能自动将网址生成超链接(可点击),如果我们每次都要通过“插入或编辑链接”这个按钮来插入链接,的确有点麻烦。其实 WordPress 提供了一个名为 make_clickable 的函数,它可以自动将网址转换为可点击的超链接。
使用方法很简单,通过 the_content 钩子挂载 make_clickable 函数即可。具体方式是在主题的 functions.php 中添加下面的代码即可:
/**
* 让 WordPress 文章的网址<a href="https://www.wpdaxue.com/tag/url" title="查看与【URL】相关的文章" target="_blank" rel="noopener">URL</a>自动生成超链接
* https://www.wpdaxue.com/wordpress-make-clickable.html
*/
add_filter('the_content', 'make_clickable'); |
/**
* 让 WordPress 文章的网址<a href="https://www.wpdaxue.com/tag/url" title="查看与【URL】相关的文章" target="_blank" rel="noopener">URL</a>自动生成超链接
* https://www.wpdaxue.com/wordpress-make-clickable.html
*/
add_filter('the_content', 'make_clickable');
注:make_clickable 函数可将 URI、www、ftp 以及 E-mail 地址转换成超链接的形式。更多说明,请查看 make_clickable 文档
来源:
https://www.wpdaxue.com/wordpress-make-clickable.html
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_32632.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57