Social Links: No need to use plugins

Social media links can help a site gain a following. They can allow people to share pages and follow your social media pages. There are several plugins that can add links for you and they can work quite well. The problem is that these plugins hook your page into a third party application. I wouldn’t have too much trouble with this on its own. These applications seemed quite well put together. Then I found that my page load speed was increasing by an average of 3-4 seconds!

Thus I began a quest to figure out how to add social media links without plugins. I decided to have two places for social media links. The first at the end of each post, allowing users to share pages. The second would be links to follow my Twitter, Facebook and Google+ pages. These would appear in the sidebar.

Twitter

The simplest way to add twitter buttons can be found on their website. It’s as simple as selecting the type of button you want and copy/pasting the code.

I wanted to have a vertical follow button like I was using for the others. There was no option for styling the button on the page. After a brief search I found this page. Here it lists a bunch of options for changing the style of the button.

Twitter code requires a URL. Each page and post in your website has a different URL so it’s not ideal to add one for each by hand. Fortunately you can replace the link with a WordPress function. If you look at the code provided you find it has something like data-url="http://www.your-link-here.com/subpage". We can add a call to get_permalink which provides the link to the current page.

The other thing you need to do is make sure that data-via references your screen name. The final code for my share button looks like this:

Continue reading Social Links: No need to use plugins

Category Pages

I wanted to split up my content in a neat and tidy way. I realised the easiest way to do this would be to split up my content by category. After trying a few plugins to create pages that displayed a list of posts in a category I realised that I needed to approach this another way.

As it turns out you can do this in WordPress easily by using Menus and Widgets. You don’t need plugins and you don’t even need to write a line of code!

The first step is to create a new menu. Under Appearance->Menus you can create a new menu. Call it whatever you want – the name doesn’t appear anywhere on your site. You can add pages, custom links or categories to the new menu. The latter is what I was after so I added a bunch of categories to my new menu.

Creating custom menus
Creating custom menus

Under Appearance->Widgets you can add new menus, search boxes, and other things to your sidebar. What I needed was a Custom Menu. Here you can give it a name that will actually appear on your site.

Attaching the custom menu widget
Attaching the custom menu widget

And that was it. I now have a new fancy menu that splits up my content in my sidebar. Now when visitors check out the site they should be able to see the kind of content that is available.

The final menu in all its glory!
The final menu in all its glory!

There was one last thing to do before I was completely done. Up until now I had been treating categories like tags, adding 3 or 4 categories to each post. I decided this would work better if I kept my categories a little tighter. So I went through all my old posts and assigned them to no more than one category each. I didn’t have much content on my site so this was a quick job for me.

When Plugins Collide

When making a new post one day I came across a bug in my website. I created a new post, attached a featured image, and hit preview. I got a messed up page that had two copies of my featured image above the page content.

As panic set in I went through and checked everything. My site still looked fine. Already published posts seemed okay. Checking previews of already scheduled posts showed that they were fine. I tested different images to see if they were the cause. No luck there either.

Continue reading When Plugins Collide

Optimising WordPress

I spent the better part of last week improving my blog, and I figured I would write about my experiences. WordPress is a great platform and I’m having fun working with it. But, like any piece of software, it needs some fine-tuning before it can work the way you want it to.

GTmetrix

My first major problem was the site’s speed. I’d always noticed that it was slow, but I never realised by how much. I discovered GTmetrix, a site that scans web pages and determines how you can improve them to make them faster. When I scanned my home page: 27+ seconds!

I needed to fix this.
Continue reading Optimising WordPress