[Plugin: Sociable] Facebook button points to wrong post (conflict with YARPP & similar plugins)
-
Not sure where to report a problem with the plugin, so I’ll just post here…
I encountered an error when using GetSocial plugin with other plugins that call get_the_excerpt() functions. Specifically, some of the buttons (like Facebook Share) will point to the last post the get_the_excerpt() was called on, and not the post being processed.
Specifically, in my case I have YARPP plugin generate 5 related posts and display their excerpts at the end of each single post (e.g. https://www.typical-human.com/oddity-1936). The Facebook Share button will then ‘point’ to the last post the YARPP generated.
The reason for it is the following.
Sociable hooks into the ‘the_content’ to cache permalink to the post as a global variable, and builds the share buttons using this variable when the footer is processed.
Unfortunately, WordPress applies ‘the_content’ filters inside get_the_excerpt() (see formatting.php line 1870), causing the Sociable to re-cache the permalink for the wrong post ID.
I am not sure how to fix it ‘elegantly’ yet, but one thing is clear – global variables are evil ??
If anyone has suggestions on a good fix, please let me know.
- The topic ‘[Plugin: Sociable] Facebook button points to wrong post (conflict with YARPP & similar plugins)’ is closed to new replies.