內容簡介
此外掛會查詢流行的社交網路 API 並從每個網站回傳分享/讚/加一/釘的數量,所有的分享數都會加總計算,給你總分享數。回傳的資訊僅是一個簡單的數字,代表分享、讚、推文、加一和釘的總數。
這個外掛可以以兩種方式使用。第一種方式是 AJAX 路徑,需要在模板中加入少量的 Javascript。如果您要在單個頁面中請求多篇文章的分享數,例如在存檔頁面,這是您應該採用的方法。以下是如何達成的快速範例:
jQuery.get(ajaxurl, {action: "get_total_shares", url: "<?php the_permalink(); ?>"}).done(function(data) {var shareNum = parseInt(data); // your total number of shares});
注意:您可以隨意呼叫這個 AJAX,但必須將 the_permalink(); 作為 url 參數,並將 "get_total_shares" 作為 action 參數傳遞。
如果您只需要顯示單篇文章的分享數,您可以使用此外掛的簡碼,以回傳相關之數量。簡碼為 [tyme_share_count] 。
此外掛還會在每次發布文章時刷新 Facebook 開放圖形圖片,以保證分享到 Facebook 上顯示合適的圖片和內容。
外掛標籤
開發者團隊
原文外掛簡介
This plugin will query the popular social network APIs and retrieve the number of shares/likes/plusones from each. All shares are added up and calculated together to give you the total number of shares. All that is returned is a simple number. This number represents the number of shares, likes, tweets, +1’s, and pins.
The plugin can be utilized two ways, the first method is the AJAX route which will require you to add a little javascript to your template. This method is the preferred method if you are requesting the share count for multiple posts on one page load. For example on an archive page. Below is a quick example of how that is done:
jQuery.get(ajaxurl, { action: "get_total_shares", url: "" }).done(function(data) { var shareNum = parseInt(data); // your total number of shares });
Note: You can call this AJAX anyway you wish, but you must pass the_permalink(); as the url parameter and "get_total_shares" for the action parameter.
If you are just displaying the share count for one post at a time, you may use the plugin shortcode to return the number. That shortcode is [tyme_share_count]
This plugin also refreshes the Facebook Open Graph scraper each time a post is published. This ensures the proper images and content are being served to Facebook when shared.
