echo
を使用してHTMLを明示的に追加すると、次のコードはうまくいきますが、何らかの理由でそれを含むスクリプトの同じディレクトリにあるマークアップファイルを含めてコードをよりきれいにしたい含まれていません。ここでは、コードは次のようになります。なぜインクルードがここで動作しないのですか?
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);
}
include(__DIR__ . '/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=600\');return false;" title="شارك على جوجل+" target="_blank">
<img src="'.$them_uri.'/images/social/Google-plus-38.png" alt="" />
</a>
</li>
</ul>
</div>
'social-links.php'やそれに類するコンテンツを共有できますか?それに何らかの警告やエラーがありますか? –
'social-links.php'の内容を含めずに直接使用すると、優れた動作をします。しかし何も出力しないとき –