I found a simple solution thanks to this answer:
How do I change the singular/plural on “comment” to “comments” on Facebook’s number of comments?
Here is how I solved without the tag, using the code I was already working for, this goes into function.php
function get_likes($url) {
$json_string = file_get_contents('http://graph.facebook.com/?ids=" . $url);
$json = json_decode($json_string, true);
$count = intval( $json[$url]["shares'] );
if ($count == 0) {
echo "share!";
} elseif ($count == 1) {
echo "shared 1 time";
} else {
echo "$count shares";
}
}
and this in the template
<?php $url = get_permalink( $post_id ); echo get_likes($url); ?>
Related Posts:
- Facebook sharing link is not showing a thumbnail of the images within the post?
- WordPress 4.4 release produce blank white images when sharing a post on Facebook etc
- Multiple social buttons with a fast loading? [closed]
- Facebook Share Thumbnail
- Facebook doesn’t display the related thumbail for some posts
- Sharing post from archive page (loop) doesn’t work
- Automatically Import WordPress Blog to Facebook Page [closed]
- How to automatically share posts on facebook?
- Embedding Facebook in blog post not working
- Facebook share thumbnail not showing until refreshed
- Send and Embed Vine (in WP Post) on Facebook
- how to add a facebook page latest posts into my wordpress site
- How to display a certain template element only for posts published within certain time range?
- Some post share on facebook didn’t show up images
- Need fixing generic posting on facebook
- How to add a post option in wordpress like facebook [closed]
- How do I check if I linked to a post before I delete it?
- How to check if post meta key exists or not in wordpress database
- Portable Post Links
- Dynamically update post title in admin page
- How can I display 7 posts on the home page, but 9 posts on the subsequent pages?
- duplicate posts when trying to update a post using the wp_insert_post.
- Add custom field to all posts in specific category
- 404 error after publishing a post
- Hiding by default specific post status on backend list?
- How to edit layout of a particular post format?
- Displaying Page Title on index.php
- Detect Post Type when publish_post is ran
- Showing Thumbnail from Previous and Next Posts
- WP_Query in functions.php overrides global $post object, even with wp_reset_query()
- How to automate filing a form as a user
- WP rest api returns 404 only when author param is used
- Reset/Reorder posts ID in the MySQL wp_posts table
- Encrypt / Decrypt Post Title and Details
- Limiting the number of posts in WP_Query leads to unexpected result
- how to set beforsend option in wordpress ajax methods
- Guest Author – How to display posts on /author/ archive page
- How to add pagination in between post and comments?
- Posts not showing on page
- Is it possible to change post id for an already added menu item in WordPress?
- WP Bakery Load More Button loads the same posts
- How do I retrieve then print the currently viewed sub categories?
- WP Query – Posts Per Page not working in combination with category__in
- Apply a style for 4 blogs and another style for the next 4 blogs in wordpress blog page?
- How to convert contact form 7 submission to post after submission? [closed]
- How to render taxonomy in loop of custom post_type
- Posting blog entries in screenplay format
- Listing Specific Categories from Current Post with Depth
- Custom Post Type Rewrite To Include Parent Page(s)
- get_the_category listing in hierarchial order
- How to automate featured posts number? [duplicate]
- Getting only the URL of the post thumbnail
- outputting posts’ taxonomies: cant get ‘get_the_taxonomies’ working
- Linking to pages/posts within the site
- Displaying posts that belong to a specific author
- Importing posts only – consequences?
- Add Post As a menu Item
- Query for first 3 posts to change the look and feel
- Getting blog pagination to work on page set as front page
- Navigate through the posts using keyboard arrows
- unique post in “$args” of wp_query display more than one post
- New Posts and Pages Won’t Save
- Why excerpt is Displaying same in Random Posts list
- How can I add 2 buttons with shortcode
- Show posts on front page only
- Get featured image on hover of post title [closed]
- How get top post view for today for today post
- Changing wp_link_pages() to “Next Page” and “Previous Page” buttons?
- My post does not show up
- Set Default Post as Parent Child (Nested) Relation
- Display Current Posts Category (with the most posts)?
- Create a List of Widgets, where each widget holds three attributes
- How to automate creating pages on a hosted wordpress from a local set of folders?
- Filter posts by month (dropdown)
- How to fetch courses in all languages in WordPress?
- Redirect old Posts URL to new URL
- Create a tree with categories with get_posts()
- How to display particular set of wordpress post on a webpage?
- Center crop the feature image
- Allow users to post their videos to my wordpress website?
- Display Custom Post Category Count & WordPress Category Count Using Shortcode
- Add Categories To Custom Post
- Display post on main page with thumbnail
- Display Posts by Categories
- Custom Single Post Type not referring to single-post-type.php File
- Custom template for different post types
- index.php is only displaying current month’s posts?
- How can I use the “Your latest posts” as a template?
- prevent same wordpress post title
- Remove duplicated posts in the loop if post has more than one category
- “Current” class on a singular page menu item with custom post types?
- get next/previous post name
- Get image paths from RSS feeds
- How do I display the next 3 posts in the sidebar?
- 2 tick boxes appearing below comments
- How can to use the players from the Media Widgets in the body of a post to play audio and video files
- Issue with wordpress pagination: last 2 posts show again on second page
- Extra Theme – Fit image inside of Featured Post Slider
- Polylang – display one post into 3 categories with different lang [closed]
- How can I show the positive and negative comments for a same post separately?