以下代碼只適用於訪問者,但如果我用socials-links.php
內容替換include()
,它對訪問者和用戶都正常工作。那麼,include()
有什麼問題。 下面是代碼:爲什麼此功能僅適用於訪客?
function render_social_links() {
$current_post_id=get_the_ID();
$them_uri = get_stylesheet_directory_uri();
$featured_image_url = '';
if (has_post_thumbnail($current_post_id)) {
$featured_image_id = get_post_thumbnail_id($current_post_id);
$featured_image_url = $featured_image_id ? wp_get_attachment_url($featured_image_id) : '';
}
if(is_home() || is_single()){
if(is_home()){
$bitlink = $lnk = get_bloginfo('url');
$bitly = getBitly($bitlink);
$nam = get_bloginfo('name');
}
elseif(is_single($current_post_id)){
$bitlink = $lnk = get_permalink($current_post_id);
$bitly = getBitly($bitlink);
$nam = get_the_title($current_post_id);
}
$bitlink =esc_url($bitlink);
$lnk = esc_url($lnk);
$nam= esc_attr($nam);
$bitly = esc_url($bitly);
include($them_uri.'/social-links.php');
}
}
這裏是社會links.php內容:
<div id="socialleft">
<ul>
<li>
<img src="'.$them_uri.'/images/social/share-38.png" alt=""/>
</li>
<li>
<a href="http://www.facebook.com/sharer.php?u='.$lnk.'&t='.$nam.'" title="شارك على فيسبوك" target="_blank">
</li>
<img src="'.$them_uri.'/images/social/facebook-38.png" alt="" />
</a>
</li>
<li>
<a href="http://twitter.com/home/?status='.$nam.' : '.$bitly.'" title="غرد" target="_blank">
<img src="'.$them_uri.'/images/social/twitter-38.png" alt="" />
</a>
</li>
<li>
<a href="https://plus.google.com/share?url='.$lnk.'" onclick="javascript:window.open(this.href,\'\', \'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=60\');return false;" title="شارك على جوجل+" target="_blank">
<img src="'.$them_uri.'/images/social/Google-plus-38.png" alt="" />
</a>
</li>
</ul>
</div>
和CSS social_links.php相關:
#socialleft{
position:fixed;
top: 35%;
left: 0;
height:100%;
width:45px;
margin-left:15px;
display:block;
z-index:100;
transition: width ease .5s;
}
那麼,問題在哪裏,你現在想要什麼? –
問題是Include使得輸出僅對訪問者可用,但是當我(管理員)或其他用戶登錄時,則沒有output.that是我所問的,爲什麼會發生這種情況? –
請啓用調試並檢查 –