Tagged: coding

One of my biggest issues with the way I constructed this blog was the necessity to define the header and thumbnail image for each post. I knew that there were easier ways to get it done, but I was not able to get the code written before I put the site live.

Before the change, I would have to add the url to the images in to custom fields of each post. If I forgot to add the image or linked to the wrong one, it was quite possible that the world would stop spinning (or it would break the layout, which is just as bad).

The Old Way
Custom Fields that needed to be filled out for every post (aka the old way)

I decided to update the php to include a bunch of if statements, which are probably not the best way to solve my issue but it works. The new code basically tells wordpress which image to display based on which category the post is in. This allows me to define the image once and it will replicate for every post. The nice thing about this is that there is one block of code that handles all of the header and thumbnail images. If I need to update the images or tweak the categories, I just have one place to look.

The New Way
The new way (aka Set it and forget it)

I had first used this method when setting up the backend code for Matt Lewis’s Blogfolio. He had needed static images to display based on which page you were on, and I realized I could modify the code to be included inside my loop and it would cut out the hassle of having to define images every time.

I am sure there are very few people that are actually interested in code updates, but if that isn’t geekdom, what it?

Updates to behind-the-scenes stuff