The past couple of days has been a little bit of website clean up and (as often is the case) an opportunity to learn. Facebook recently released their own plugin for WordPress. And I couldn’t resist giving it a try. Now, my “Like” buttons and all are hard-coded into my theme, so I really don’t need those but the “Recommendations bar” and the ability to @ mention people and pages in my posts are pretty cool features that I hadn’t previously even thought of trying to integrate. I figured Facebook’s plugin had to be better than the rest. Hence why I had abandoned all but one plugin that handled putting the Facebook open graph metadata in my headers. And honestly I wanted to code that into my WordPress setup as well but just hadn’t had the motivation to tackle it. There are actually a lot of moving pieces to provide Facebook the image to use with a like or share as well as the title and description for posts and pages on WordPress.
My verdict on the new plugin so far is that it’s better than the rest and I think the team working on it will continue to respond to feedback and refine the plugin. As it stands I’m only using a couple of features from it. I’m still using my own buttons for posts and pages because I want to include more than just Facebook’s button (in fairness it’s not likely that Facebook will include Google’s +1 button or a Stumbleupon button). I’ve also ended up adding a Facebook comment box because the current iteration of Facebook’s plugin overrides the WordPress defaults system. I have two issues with this. The first is that it means any reader who wants to comment must have a Facebook account. That’s not incredibly democratic. I want people to be free to respond in the manner of their choosing. The second issue is that those comments reside on Facebook’s server. If I ever remove that feature, I lose those comments. Instead I’ve gone for an either/or approach. I’ve added the code for Facebook’s comments but left in the regular commenting system. We’ll see how that approach works. I would still lose the Facebook comments if I remove it from my site, but additional engagement might be worth that.
So, I mentioned learning didn’t I? Well, that was the “fun” part. I’ve been following a very hacky approach to my websites. I’ve been using a Theme I really like for a couple of years now. It has a ton of options to customize it without touching the code at all! Despite all that ability to customize, I’ve gone past that for quite awhile. All those buttons and what not have involved getting dirty in the code, which has had a house of cards effect. Anytime the developer updates his code if I want to use it, I have to re-do all my changes. It’s telling that I have a text document with snippets of code and notes on where they belong. I made my own instruction manual!
Granted I had gotten detailed and all, but there really is a better way, and it’s handled through child themes and the developer was nice enough to include instructions on how to do it. Even with the instructions, it required some trial and error, but it’s done! And it feels so nice not to have a house of cards every time an update rolls around.
I still have one little hack left, though. I realized yesterday that the open graph code from Facebook for reasons I can’t guess does not pick up images for static pages on my site, just from blog posts. I don’t know if it’s something in particular about the theme I use or if it’s a peculiarity of the way they’ve coded the plugin, but it simply doesn’t pass the proper og:image variable to Facebook in the header where the old plugin I used did. I did post this issue to the support forum and so far the help I’ve gotten is above my head. I couldn’t see quite how to put the proper code in my functions file that would override their plugin. However, I already have code in there that tells Pinterest what image to use for my pin-it button and I hacked that into Facebook’s plugin code. I know like with the child theme there must be a better way as this means each time Facebook updates this plugin I’ll need to be prepared to re-hack it.
Maybe in a few months I’ll report back that I learned that trick as well! But right now I’ve reached my fill of PHP code. It’s still light years past my site of a few years ago where virtually every page on the site was hand-coded PHP! I’m glad I could do that, but piggy-backing off an existing platform like WordPress is light years better!