我有以下功能有條件地顯示共享鏈接。所以當它是主頁時,它會顯示單個頁面的不同列表。但它適用於家庭,而在單個帖子中則沒有顯示任何內容。 她是我的代碼爲什麼這段代碼無法正常工作?
function social_links(){
if(is_home()){
$bitlink = $lnk = get_bloginfo('url');
$nam = get_bloginfo('name');
}
$current_post_id=get_the_ID();
if(is_single($post->ID)){
$bitlink = $lnk = get_permalink($current_post_id);
$nam = get_the_title($current_post_id);
}
$them_uri = get_stylesheet_directory_uri();
$bitly = getBitly($bitlink);
$url = wp_get_attachment_url(get_post_thumbnail_id($current_post_id));
echo '<div id="socialleft">
<ul>
<li>
<img src="'.$them_uri.'/images/social/share-64.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-64.png" alt="شارك على فيسبوك" />
</a>
</li>
<li>
<a href="http://twitter.com/home/?status='.$nam.' : '.$bitly.'" title="" target="_blank">
<img src="'.$them_uri.'/images/social/twitter-64.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-64.png" alt="+شارك على جوجل" />
</a>
</li>
<li>
<a href="http://pinterest.com/pin/create/button/?url='.$lnk.'&media='.esc_url($url).'" title="" target="_blank">
<img src="'.$them_uri.'/images/social/pinterest-64.png" alt="شارك على بينترست" />
</a>
</li>
</ul>
</div>';}
我使用的功能到包含
<?php
/**
* The main template file.
*
* @package Brandon
* @author Muffin group
* @link http://muffingroup.com
*/
get_header();
?>
<!-- #Content -->
<div id="Content">
<div class="content_wrapper clearfix">
<!-- .sections_group -->
<div class="sections_group">
<div class="section">
<div class="section_wrapper clearfix">
<?php
echo '<div class="posts_wrapper clearfix">';
while (have_posts()){
the_post();
get_template_part('includes/content', get_post_type());
}
echo '</div>';
// pagination
if(function_exists('rc_pagination')):
rc_pagination();
else:
?>
<div class="nav-previous"><?php next_posts_link(__('← Older Entries', 'brandon')) ?></div>
<div class="nav-next"><?php previous_posts_link(__('Newer Entries →', 'brandon')) ?></div>
<?php
endif;
?>
</div>
</div>
</div>
<!-- .four-columns - sidebar -->
<?php get_sidebar(); ?>
<?php render_social_links();?>
</div>
你是華麗的,你的答案更有意義,但我已經做了所有的建議,但仍然沒有顯示。我會編輯我的代碼到問題 –
是的,請分享你現在有什麼然後我們可以進一步幫助你和你的代碼。 – hellofromTonya
@MohamedOmar我修改了你的新修改代碼的答案。試一試。 – hellofromTonya