xiu主题“直达链接”修改为“自定义名称”教程

为直达链接增加了自定义直达链接功能,增加前只显示“直达链接”。增加这个功能,修改了两个文件functions.xiu.php和functions.admin.php,其中functions.xiu.php文件增加判断是否自定义直达链接并显示,找到

function hui_post_link(){
    global $post;
    $post_ID = $post->ID;
    $link = get_post_meta($post_ID, 'link', true);
 
    if( $link ){
	echo '<a class="post-linkto'. (is_single()?' action':'') .'" href="'.%20$link%20.'"'. (_hui('post_link_blank_s')?' target="_blank"':'') . (_hui('post_link_nofollow_s')?' rel="external nofollow"':'') .'>'. (is_single()?'<i class="glyphicon glyphicon-share-alt"></i>':'') ._hui('post_link_h1') .'</a>';
    }
}

修改为:

function hui_post_link(){
    global $post;
    $post_ID = $post->ID;
    $link = get_post_meta($post_ID, 'link', true);
    $linktitle = get_post_meta($post_ID, 'linktitle', true);
 
    if( $link ){
		if($linktitle){
			echo '<a class="post-linkto'. (is_single()?' action':'') .'" href="'.%20$link%20.'"'. (_hui('post_link_blank_s')?' target="_blank"':'') . (_hui('post_link_nofollow_s')?' rel="external nofollow"':'') .'>'. (is_single()?'<i class="glyphicon glyphicon-share-alt"></i>':'') .$linktitle.'</a>';
		}
		else{
			echo '<a class="post-linkto'. (is_single()?' action':'') .'" href="'.%20$link%20.'"'. (_hui('post_link_blank_s')?' target="_blank"':'') . (_hui('post_link_nofollow_s')?' rel="external nofollow"':'') .'>'. (is_single()?'<i class="glyphicon glyphicon-share-alt"></i>':'') ._hui('post_link_h1') .'</a>';
		}
 
    }
}

functions.admin.php文件增加后台自定义直达链接填写框,找到

$postmeta_link = array(
    array(
        "name" => "link",
        "std" => "",
        "title" => __('直达链接', 'haoui').':'
    )
);

修改为:

$postmeta_link = array(
    array(
        "name" => "link",
        "std" => "",
        "title" => __('直达链接', 'haoui').':'
    ),
	array(
		"name" => "linktitle",
        "std" => "",
        "title" => __('直达链接标题', 'haoui').':'
 
	)
);

 

© 版权声明
THE END
喜欢就支持以下吧
点赞0赞赏
分享
评论 抢沙发