主机优惠
信息分享

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').':'
 
	)
);
赞(0)
欢迎转载:VPS推荐网 » xiu主题修改之直达链接修改为自定义名称