It’s been a while since i wrote an article for this series. All the “masochists” out there must be wondering. The truth is that firstly there was no interesting topic to write about and secondly it is pretty hard to write such an article since it needs a lot of research from my side. Anyway, yesterday i got a comment from Kim on the revisions removal here. What she is asking is a way to change all the articles from the “Uncategorized” category to another one through the database rather from the WordPress administration. It sounds pretty reasonable since she claims she wants to do so for over a thousand posts. Obviously, using the admin is not an option. To go through this i feel it’s necessary to see how WordPress stores categories and the relationship with the posts.
You know i’m all for “If you can do it yourself then don’t use a plugin”. That goes, without saying, to my plugins too. So, i saw a plugin recently doing a very useful thing, cleaning up post revisions. But what is a post revision? Well, it’s a safety measure the WordPress team took since version 2.6.X to protect your writing from unfortunate circumstances that may occur. Moreover, it’s a way to have different versions of your posts. When you write you tend to delete and start over. At some point you might want to go back and see what your post looked like back then. Pretty much this is what post revision is.
But, when you are done with a post, you most probably will not use that ever again. So, think about having ten versions of a certain post, or even worse, ten versions of many posts. That’s a lot of unnecessary info and clutter for your database. To give you the whole picture, post revisions rest in the table that your actual published posts are. This is bad in two ways. One, it’s making it harder to index and make a query on the table. Even worse, when a query joins this table with another one then the result of the join will have a lot of junk lines, therefore, alot of no needed info. Two, imagine a post replicated ten times on your database. It could be like 60Kb or even, much more. Now that is alot of fragmented space. For this reason it’s a very good idea to remove post revisions.
The plugin can do the job for you but, as i already said, this is a trivial job and you can easily do it by hand. All you need to do is run a simple SQL query on your database and you will be done. Before going any further please make sure you keep a backup of your database for the scary moment that something goes wrong. Open your sql manager (either console or phpmyadmin or whatever you use to access your database). Run this query:
You are done! Please make sure you type exactly this and nothing less or you might be in serious trouble. Now, just to improve things for you, you might want to delete all revisions that are older than a month. This is what you are looking for:
This deletes all revisions that are older than a week today. So, go ahead and get rid of all the clutter. When i did so, i reduced my database’s size by 1.2Mb! I know, impressive huh? Keep one thing in mind though, backups, backups and more backups. The more the better
In the past i have been negative on advertising on any of my sites. I then twisted that and opened the “Member of the Month” section where the top commenter gets his banner on my sidebar free of charge for a month. This was not all that bad since it is actually a way to say thanks to a frequent visitor and commenter. My point of view is that i blog for fun and not for money. This hasn’t changed actually. What has changed is that i moved onto a better server, meaning bigger costs for me. I am not saying that i can’t finance the expenses myself but it would take a bug burden of my shoulders if the server was all paid for. So, i came up with a minimum of an advertisement campaign.
There is a thin line i am trying not to cross. On one side is a blog clean enough to be easily readable and not annoying to my visitors and on the other side is putting ads on a spot that is a good place for advertisers well worth their money. So, here is what i decided to do. I am going to try make the costs from having two advertisements on the top right corner, making enough money just for my server. I will not put them on any other place so it won’t get messy.
I am really curious and anxious to see if this is going to work out, to actually see if someone thinks five bucks is cheap enough to buy a spot here. If it doesn’t, and the spots remain empty for a period of time, i will remove them and cancel the whole thing. In that case i’ll just have to keep going as i am right now.
So, bare with me people. I am experimenting with this. What do you think? Is it worth it? Is it too expensive? Should i got to $2.5 maybe? I guess time will show…
On my early days of computers and programming i used to be fanatic and passionate about the programming tools I used. I still remember the early days of Java programming. I would bet that no other language is there except for Java. Today, i still think that it is a great language to work with but i have changed my point of view.
All languages, frameworks, programming techniques etc are all tools in a big toolbox a programmer has. The variaty of things he knows actually gives him the necessary equipment to deal with the daily challenges he faces. It’s all wrong to think that one tool is the best to be applied in any program you are trying to code. Once they provide you with details on what you need to be doing, on what hardware, what software then you should start considering all your options. For instance, not long ago, i needed to code a small application, along with a friend, that had to be windows compatible, be able to minimize to tray and integrate with the OS is some other ways too. The things it needed to do were fairly simple. So, for that matter, why should we go with Java? We would have to code a lot, so we could add structure for Object Orientation, without thinking the ways we would have to invent on how to integrate with Windows. I know it’s possible but think about this. Why not Visual Basic? I mean it’s .Net compatible and the things we needed to do were done extremely easily. That’s what we actually did and got it done in three days.
Here is another example that actually gave me the idea to write this article. Let’s say you want to put up a little website that all it does is actually have a few info about you and maybe some photos. Why should you start coding PHP? What would that add to your project? Absolutely nothing! The only thing it could do is add complication to what you are trying to accomplish and maybe set you wide open on dangers like SQL Injection. Moreover it would be much slower than writing simple, easy renderable, HTML. The general rule is that when you have static content (that is content that does not change over time and is not a variable of some kind of input) then HTML is the way to go. Ofcourse, there can be exceptions, depending on what exactly you want to do. Keep your toolbox near by!
Now think it the other way around. Let’s say you want to open a big community site with news on a certain topic. Would you choose WordPress for that? Well it depends. But, if you wanted a true CMS that is scalable then probably our beloved WP wouldn’t do.
My point here is this. When you are trying to get a job done you need to get an objective perspective on the subject. Analyze all the scenarios and come up with the best solution that would actually work and not the one you are accustomed with. I have one saying that i keep in mind when trying to choose the best tool out of my toolbox:
Don’t use a cannon to kill a mosquito.
- Confucius
Keep that in mind and you should be just fine.
This post will be a conclusion on the requests for plugins and tweaks requested over at Kim’s blog. Both her and a reader of her’s, SDK, requested on a small tweak on the plugin called “Search Reloaded”. The plugin does a very good job on serching posts for you. It actually enhances the search feature alot by sorting not by date but by relevance. To be exact it sorts with these criteria (and in this order):
It’s actually a pretty good approach, surely much better than the plain “sort by date” that WordPress has by default. The tweak that was requested was this. The plugin should search in the comments of a post too. That’s rather reasonable. Now, i can’t modify the plugin and let you have it from here, since the license is non-GPL. But i can post the tweak and you can do it yourself. So here it is…