Category: wordpress

A few weeks ago I started the process of moving this blog over to WordPress from Ghost—and I talked about why I did that in a previous post—so now that I’ve made the change, the next natural step felt like talking about how I developed a theme for the first time.

Yep, I’ve never done this before, and it turned out pretty well… I think.

I did what I never thought I’d end up doing. Over the last month, I’d been contemplating moving away from Ghost as a blogging platform and back to WordPress. Back in June I moved away from WordPress. My original complaints were related to complexity, bloat, and performance. I felt WordPress was becoming too slow and complicated for a simple blog like this one. I watched as Ghost became a more mature and baked tool so I dove in. Wiring up a design for it was a trivial matter, something I greatly appreciate still. The simplicity in design wasn’t enough to keep me, however, along with a few other reasons.

Ever since I started this blog up again at the beginning of January, I wanted to have related posts be visible at the end of each post. I use JetPack and I figured turning Related Posts on would be easy and I would be all set.

Well, not so much.

I turned on Related Posts and discovered nothing was appearing. I knew there wasn’t really anything that could be wrong as I don’t have any errors in WordPress, PHP-FPM doesn’t report errors in any of my logs, and I can use other services like WordPress.com Stats and the like.

I did some digging and after my search turned up nothing, I reached out to Automatic support and asked about my JetPack issue. We worked through a few things including making sure WordPress.com Stats was working, the JetPack servers could see my site (which they did). We even checked to make sure the plugin was even grabbing data to display in the first place. This can be done by adding ?relatedposts to the end of any single post URL. You’ll get a JSON blob in return if it’s doing what it’s supposed to on the back end. We figured, well, that can’t be it either. Turns out, the answer wasn’t anywhere where I was expecting it to be.

My problem was with my Nginx server configuration for this site.

Here’s where it gets technical. For any path, you’ll have a set of URIs for the server to try before it gives up. The code usually looks like this:

try_files $uri $uri/ /index.php

In most cases, that’s right! WordPress will work just fine like this. You won’t notice errors and everything will parse fine… except for JetPack’s Related Posts plugin.

See, with the above line of code, we’re telling Nginx that it’s ok to try the URI by itself, with a slash after it, or try index.php by itself, depending on what the URI actually is. Nginx, however, is very detail-oriented and will only do exactly what you tell it to do. In my case, I left out a specific instruction: process index.php with arguments, please. By doing so, we turn the above line of code into this line of code:

try_files $uri $uri/ /index.php?q=$uri&$args

JetPack calls upon that JSON blob I told you about a bit ago just like that: index.php followed by the URI (not fancy, something like a post ID), and any additional arguments necessary after that. So in the case where my post ID is 105 and it’s grabbing the related posts for that, it would be calling

index.php?q=105&relatedposts=1

Boom.

I hope you find this helpful. If you did (or did not), leave a comment below.

Let’s be honest. The year is 2015 and nobody wants to do things by hand or manually if they can help it. Companies are hiring people to automate the hell out of everything because like M.I.A (sort of, not really) famously rapped:

“live fast, die young, robots do it well.“

I’ll admit, I like speeding up the process of sharing what I’ve written but I like controlling it a bit more than some. Here’s how I do it.

You’ll want to create an account with IFTTT and Buffer if you haven’t already. IFTTT stands for IF This, Then That. The premise is that you can take data being expelled from one service, and based on certain criteria, do something with it via another. Things like “Text me with the daily weather report at 5AM” are easy and, well, kind of cheesy. If you become a power user of IFT.TT or already are, you’ll know that there’s so much more you can do with the service like auto-tweet breaking news stories from news sources or trigger your Philips Hue home lighting to change color when a storm warning comes into effect.

In my case, I want to sync IFTTT with my WordPress install. To start, I’ll need to create a new recipe and click on the blue this link (A) and choose the WordPress trigger channel (B). This will be the source for the data that IFTT uses.

Once I have that set, I can choose whether I want this action to be triggered by any new post from WordPress, or just when the post has a particular tag or category. In my case, I choose the former, because I want to share all posts.

We can skip Step 3 as there’s nothing else to set for these triggers and move on to step four. Click Create Trigger.

So at this point we’ve established that if there’s any new post on WordPress Blog then we’ll do something. Now we establish what that something is. Click the blue that link. In my case, I want to share to Buffer.

I will want to choose the “Add to Buffer” option since I won’t be pushing photos from my source. My final step is to set up how I want my shares to look and then I create my action.

Note: If this is your first time, you’ll have to set up what account you want Buffer to schedule this IFTTT-pushed content on.

There are a couple things to keep in mind when setting this up. Anything pushed from IFTTT to Buffer: 1) will be set to whatever schedules you have created and 2), will only be pushed to whatever social media account you have set up for this channel. You can only have one social media account chosen for this type of setup.

If you want to use more than just one social media account to share you content, I recommend creating separate recipes for each. Granted, only one of them will be scheduled via Buffer, so keep that in mind. In my situation, I don’t really mind, and I use Buffer so much already that I like having the ability to manually schedule for other social media accounts that don’t get as much regular pushing of content.

All Done!

It’s that simple. If you have account with IFTTT and Buffer already set up, this will take you thirty seconds to do. You’ll find this thirty seconds will save you time in the long run and will become something that you don’t even think about at the end of the day.

Sure you could use WordPress plugins, too, and that’s all fine and dandy. I’m not stopping you! This is how I like to do it and I figured someone out there might like to know.

A rather odd thing started happening shortly after I implemented Jetpack on this site. I was seeing my posts show up on twitter, which is nice and all, but not through the method I had set up. I describe how I set up automatic post scheduling for the various social networks in this past. These tweets were being written without a fancy permalink, which seemed odd and told me that it wasn’t something of my intentional doing. After doing some research, I discovered someone having an issue with the Publicize plugin not removing a social media account properly. In order to fix their issue, they re-added their account and removed it again.

I figured it would be a stretch but I knew it couldn’t hurt anything so I tried that myself just to see what would happen. I Added my Facebook page, and after authorization, lo and behold, my twitter account showed up, too. It wasn’t previously authorized so I had a pretty good idea this ghost authorization was what was causing these unwanted shares. Un-linking my twitter account immediately solved the problem, and I was on my way to sharing the way I want to: WordPress > IFTTT > Buffer.