/ Wordpress

为Wordpress博客 添加文章分享按钮

百度分享分享文章抓取不到文章内的图片,索性换成了“加网分享”,将以下代码添加至主题 functions.php 文件内,便可实现网页分享功能。如果您使用了ssl证书请尝试使用百度分享。

<code class="language-php">// 添加 加网分享按钮
function jiathis_scripts() {

    if ( is_page() || is_single() ) {

//这里的uid 移至http://www.jiathis.com/ 注册获得
        wp_enqueue_script( 'jiathis', 'http://v3.jiathis.com/code/jia.js?uid=2138741', array(), '202141212', true );
    }

}
add_action( 'wp_enqueue_scripts', 'jiathis_scripts' );


function add_jiathis_content($content) {
    if(is_page() || is_single()) {
        $content = $content .'<div class="jiathis_style">
<span class="jiathis_txt">分享到:</span>
<a class="jiathis_button_qzone">QQ空间</a>
<a class="jiathis_button_tsina">新浪微博</a>
<a class="jiathis_button_tqq">腾讯微博</a>
<a class="jiathis_button_renren">人人网</a>
<a class="jiathis_button_kaixin001">开心网</a>

<a href="http://www.jiathis.com/share?uid=2138741" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank">更多</a>
<a class="jiathis_counter_style"></a>
</div>

<script type="text/javascript" >
var jiathis_config={
    data_track_clickback:true,
    siteNum:7,
    sm:"tsina,weixin,cqq,qq,qzone,copy,ishare",
    summary:"",
    boldNum:4,
    shortUrl:false,
    hideMore:false
}
</script>';
    }
    return $content;
}
add_filter('the_content', 'add_jiathis_content');
为Wordpress博客 添加文章分享按钮
Share this