Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Store SNS share value via function.php

Within a function or method, the return statement immediately stops the execution of the earlier.

Hence the last line never gets interpreted.

Switch the order of this:

return $social_score; 
update_post_meta($post_id, '_social_score', $social_score);

to this:

update_post_meta($post_id, '_social_score', $social_score);
return $social_score;

Update:

You are using three different variables for the post id, namely: $post_ID, $post_id and $post->ID. You should use the function argument: $post_ID.

Related Posts:

  1. How to generate “og:image” meta for Facebook sharing when the image in the post is not featured?
  2. Automatically add simple custom buttons for print, Facebook share, & Tweet in Posts [closed]
  3. How to integrate Facebook Share button without code?
  4. Whenever I am sharing a post wordpress phrase is automatically added, can anyone help?
  5. Post image lacking when pasting link into Facebook despite the correct og:image meta tag
  6. Trouble displaying featured image as thumbnail when using Facebook share
  7. No post image when pasting link into Facebook
  8. Featured image not showing on facebook share
  9. Featured Image and Facebook
  10. Facebook and Google+ sharing suddenly stopped working properly in WordPress
  11. Retrieving Default Image All Url Profile Picture from Facebook Graph API [closed]
  12. Official Facebook Connect button as PNG
  13. Use Device Login on Smart TV / Console
  14. Invisible characters – ASCII
  15. When do I need a fb:app_id or fb:admins?
  16. When do I need a fb:app_id or fb:admins?
  17. Warning: Each child in an array or iterator should have a unique “key” prop. Check the render method of `ListView`
  18. Warning: Each child in an array or iterator should have a unique “key” prop. Check the render method of `ListView`
  19. og:url is driving me crazy?
  20. Face recognition via facebook API
  21. FB is not defined javascript
  22. What are App Domains in Facebook Apps?
  23. How can I control the Facebook like image? [closed]
  24. How can I auto-add my posts to my site’s Facebook fan page?
  25. Automatically Facebook Debug Posts on Publish [closed]
  26. If your blog was an app on Facebook
  27. Get FaceBook Friend Count [closed]
  28. Facebook OAuth, WP_Http::request() vs wp_remote_request()
  29. Change meta tags programatically
  30. W3 Cache plugin and Facebook sharing [closed]
  31. FB – Comment Moderation Tool bug? [duplicate]
  32. Any Facebook component doesn’t work on WordPress website after update. Why?
  33. Facebook sharer and parameters in URL
  34. How to control Facebook share information for the front page?
  35. sharing video on facebook from wordpress
  36. Adding a “most liked post” box, based on facebook ranking?
  37. Open graph metadata isn’t pulled on Facebook until after I run that specific link through the debugger
  38. facebook like – image display and description
  39. Is there a method or plugin that will allow posts to be sortable by Facebook likes?
  40. How do I create a page for users to invite their facebook friends?
  41. Which social connect plugin do you recommend? [closed]
  42. Facebook Like Button in Jetpack [closed]
  43. Open graph problem: Showing wrong description of homepage while sharing on Facebook [closed]
  44. How do I remove all hyperlinks that begin with a #?
  45. Multiple social buttons with a fast loading? [closed]
  46. Simple plugins to post info about new blog entries?
  47. Facebook link to website logo
  48. Get User’s Facebook Photos as WordPress Upload
  49. Trigger a function immeditely after a user posted a comment
  50. Hiding styles from Facebook
  51. RSVP form for Facebook events from a WordPress post?
  52. WordPress comments and Facebook comments
  53. Building a Member Directory Site on WordPress with Facebook API Integration?
  54. WP_Cron script not updating all posts in loop
  55. How to let user select role upon registration in Facebook-AWD?
  56. What is generating my meta og:description?
  57. Choices for thumbnail image in a Facebook Link post
  58. Displaying Facebook comments count with tag
  59. How to preserve exact formatting when copy pasting from Facebook into WordPress (or elsewhere)?
  60. Send Facebook server-side event using shortcode and Official Facebook Pixel plugin
  61. Posting to Facebook via WordPress – 500 Internal Error
  62. Sharing images to social media – issue with aspect ratio
  63. Remove text from my Facebook posts
  64. How can I echo og:video url, if the post has video content?
  65. fb share site shows blank image
  66. Facebook / LinkedIn share page – https opengraph issues [closed]
  67. Facebook preview Open Graph Object Debugger
  68. Facebook share functionality in wordpress loop
  69. Integrating Facebook calender to WordPress
  70. Open Graph in posts loop page
  71. Facebook social publisher and custom post type fields [closed]
  72. Is there a way of putting the facebook social plugins into page template php files?
  73. Conditional Facebook Share and Like links [closed]
  74. FB Comments box post to wall?
  75. How to add FB like + share AND also other Social Buttons on ALL pages and posts?
  76. Website Preview Graphic for WordPress Site
  77. How do I set a featured image for the homepage? [closed]
  78. Can’t access site after plugin activation
  79. Use Facebook PHP SDK from WPBook
  80. Integrate open graph protocol without plugin?
  81. Adding a list of social media links
  82. I want to enable facebook connect how to do this?
  83. Facebook share image wrong on post not on debugger [closed]
  84. file_get_contents_curl pulling wrong values
  85. Facebook Registration Tool: how to use in WordPress? [closed]
  86. Facebook Like – Display counter starting at Zero?
  87. How to see more WordPress images when posting to Facebook
  88. WP REST API – log in with Facebook
  89. How to implement custom buttons into individual posts?
  90. “This site is under development” when sharing on Facebook
  91. How to use author’s avatar as Facebook post preview image when a single post is shared
  92. SFC Problem with the comment login
  93. Single article separated into multiple pages makes Facebook Like button detect as completely separated articles
  94. Simple Facebook Connect: Access tokens not found
  95. Load facebook php sdk problem
  96. Unprotected page appears protected when posted to Facebook (S2Member)
  97. Facebook comment url is unreachable
  98. WordPress > Error when pasting link into Facebook
  99. How to install Facebook, Google+, & Twitter LIKE buttons for each individual post at frontpage?
  100. Facebook profile pic used as avatar
Categories facebook Tags facebook, post-meta, social-sharing
Display background color or image with custom meta box?
Insert custom fields to a custom post type

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress