最近发现一个站点有点意思,首先确定是wordpress的程序,他有几篇文章点文章标题进入的是其他地址而不是文章详情页,于是571分享家就研究了下。
发现有几种方法可以实现:
→ 点此获取正规游戏试玩赚钱软件~
1、插件实现
可用的插件有 Page Links To 或 WP Post Redirect。
2、给文章添加自定义字段
在主题的 functions.php 添加下面的代码:(文件地址:网站根目录/wp-content/themes/主题名文件夹/functions.php)
/**
* WordPress 文章标题链接到站外链接
*/
function link_format_url($link, $post) {
if (has_post_format('link', $post) && get_post_meta($post->ID, 'LinkFormatURL', true)) {
$link = get_post_meta($post->ID, 'LinkFormatURL', true);
}
return $link;
}
add_filter('post_link', 'link_format_url', 10, 2);
3、修改模板函数functions
在主题的 functions.php 添加下面的代码:(文件地址:网站根目录/wp-content/themes/主题名文件夹/functions.php)
/**
* WordPress 文章标题链接到站外链接
*/
function link_format_url($link, $post) {
if (has_post_format('link', $post) && get_post_meta($post->ID, 'LinkFormatURL', true)) {
$link = get_post_meta($post->ID, 'LinkFormatURL', true);
}
return $link;
}
add_filter('post_link', 'link_format_url', 10, 2);
新建wordpress文章,在文章末尾的自定义字段里面的名称选择:LinkFormatURL ,值:输入你需要文章标题跳转的url地址,正常发布文章即可实现上述功能。