我有以下功能有条件地显示共享链接。所以当它是主页时,它会显示单个页面的不同列表。但它适用于家庭,而在单个帖子中则没有显示任何内容。 她是我的代码为什么这段代码无法正常工作?
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