post

手动优化WordPress单篇文章页面

在这个社交网络流行的年代,我也喜欢在文章页面加入各种社交内容,Wordpress中插件很多,但是加入到页面的位置,往往不称心如意,我喜欢自己手动加入,灵活性更高。下面简单介绍如何自己加入,版权声明、无觅相关文章及JiaThis分享功能。

在single.php页面的相应位置插入下面代码:

<!-- 版权声明 -->
<div style="margin:10px;padding:10px;">除非注明,文章均为<a href="<?php bloginfo('url'); ?>" title="欢迎浏览 <?php bloginfo('name');?> 的博客" ><?php bloginfo('name');?></a>原创,转载请以链接形式标明本文地址。<br/>
本文地址:<a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>"><?php the_permalink() ?></a>
</div>

<!-- 浮动于右侧的JiaThis分享按钮 -->
<div style="float:right;">
<!-- JiaThis Button BEGIN -->
<div id="ckepop">
	<span class="jiathis_txt">分享到:</span>
	<a class="jiathis_button_tsina"></a>
	<a class="jiathis_button_tqq"></a>
	<a class="jiathis_button_renren"></a>	
	<a class="jiathis_button_qzone"></a>
	<a href="http://www.jiathis.com/share?uid=1543310" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank">更多</a>
	<a class="jiathis_counter_style"></a>
</div>
<script type="text/javascript" src="http://v2.jiathis.com/code/jia.js?uid=1543310" charset="utf-8"></script>
<!-- JiaThis Button END -->
</div>

<!-- 无觅相关文章,需要安装无觅插件 -->
<p style="clear:both;"></p>
<div id="wumiiDisplayDiv"></div>

<p style="clear:both;"></p>
<!-- 输出前一页与下一页,配合css可实现单篇页面的翻页 -->
$output = ''; 
$prev_post = get_previous_post();
if ($prev_post){
 $output .= '<span id="previous_post"><a href="'.get_permalink( $prev_post ).'" title="&#x4E0A;&#x4E00;&#x7BC7;&#xFF1A;'.$prev_post->post_title.'" rel="prev">&#8249;</a></span>'; 
}

$next_post = get_next_post(); 
if ($next_post){ 
 $output .= '<span id="next_post"><a href="'.get_permalink( $next_post ).'" title="&#x4E0B;&#x4E00;&#x7BC7;&#xFF1A;'.$next_post->post_title.'" rel="next">&#8250;</a></span>'; 
}

echo $output;

<!-- 输出文章的浏览量,需要 WP-PostViews 插件 -->
if (function_exists('the_views')):
  the_views();
endif;

Comments

  1. 博主文采很好呀,说的很精彩,以后常来混哈哈,http://www.cnoz.org

Speak Your Mind

*

· 958 次浏览