October 13, 2009
HTML, Web 2.0, Web Development
No Comments
As I begin to wrap up my first child theme using the Thematic framework, I must admit that I’m beginning to really appreciate the power of theme hooks. At first I was modifying the css to get where I wanted to be, for example altering margins, using the background url directive to add my custom header image. But when I got to the point where I wanted to suppress the display of the blog title and description, that is when I first found out about Thematic add and remove actions.
Oh sure I could have just used “display: none” in the css blog title class/ids so that the blog title didn’t display over my custom image, but that’s kind of ugly. Using remove_action in my functions.php file is much more elegant.
function suppress_header_elements() {
remove_action('thematic_header','thematic_blogtitle',3);
remove_action('thematic_header','thematic_blogdescription',5);
}
add_action('init','suppress_header_elements');
And the bonus is that the blog title description value still populate my title and meta description tags as desired for SEO optimization.
Theme hooks is not a concept unique to Thematic but embedded in Wordpress itself. Using theme hooks in your child theme, the idea is that you can isolate your customizations in a single file in a functions.php file (it may be called something different such as custom_functions.php with other frameworks).
Although I had altered the css to add my image, I wanted to additionally add clickable button images as well that I already had defined in a css file. No problem, I just created a new function called add_buttons in my functions.php file, echo’ed out the HTML and then added the add_action line:
function add_buttons() {
echo ....
}
add_action('thematic_header', 'add_buttons');
It wasn’t completely smooth sailing as I ran into this error when I tried to use the admin (error text modified to remove site identifying info)
Warning: Cannot modify header information - headers already sent by (output started at /home/mysite/public_html/blog/wp-content/themes/childtheme/functions.php:43) in /home/mysite/public_html/mysite.com/blog/wp-includes/pluggable.php on line 865
Most of the information you get googling this error suggests there is extra spaces prior to the php start tag in the wpconfig.php file. That wasn’t the case here, but it was a good clue. Turns out I had an extra blank line after the closing php tag in my functions.php file. When I finally figured out to remove that, the errors went away.
September 3, 2009
Web Development
1 Comment
After poking around at both Hybrid and Thematic, wordpress frameworks, I went with Thematic. The reason? Better documentation. I followed Hybrid’s instructions on installing a child theme and and got a broken theme. I was more successful with Skelton, but felt overwhelmed by the amount of work I need to do in css land to get to a reasonable looking theme. So in the end I installed Thematic which has some basic layout css files prepackaged to get you started with your child theme. Of course my decision to go with Thematic may reflect some learning challenges on my part, but in the end, Thematic got me quicker to where I needed to be.
Note this project is for a separate blog, not this one. The cobbler’s children makes do with last year’s shoes.
A bit more on frameworks and why you should care. Using a WP framework gives you some separation between functionality and presentation, always a worthy goal. And it allows you to subclass (well kind or) distinct functional components while preserving the ability to upgrade the originals. What I mean by this, is that you can copy a php file (say header.php) from the parent theme to your child theme directory and alter the copy. Wordpress, in it’s later versions, knows to look first for the php files in the child theme. The idea here is that when wordpress and the parent theme is upgraded, there is some insulation … I’ll let you know how that goes when I get there.
I mentioned that I went with Thematic because of the better documentation. It took a little digging, but this tutorial series of blog posts are really helpful to get you started. I particularly appreciated the pointer to a sample xml file you can import into your theme to help QA it and review all the little styles you might want to customize. That in itself was a nice find.
August 23, 2009
Web Development
No Comments
After my troubles in hacking this theme to look more colorful (and not being satisfied with the results – it’s not particularly clean looking) and also due to incompatibilities with upgrading – I have started looking into theme frameworks and child themes as a way forward for myself and my clients.
There are two I am looking at: “thematic” and “hybrid”
August 14, 2009
Web Development
No Comments
Ok, I must have done this wrong. Or maybe I was on too old of a version of wordpress.
I wanted to install sociable, a popular wordpress plugin that makes it easy for your visitors to digg, facebook, etc.. your blog posts. However the most recent sociable version did not work with my current version of wordpress 2.3.3, which is quite old. It was obviously time for me to upgrade wordpress.
Installing wordpress is a snap, but it seemed less clear how to upgrade. The wordpress codex seemed indicate I should download the latest version .. but I was a little concerned about overwriting all my customizations, it also mentioned that my hosting provider might provide some point and click support for what I wanted to do.
Excellent! I thought (I can be really lazy about this stuff)
I use bluehost. Since I have installed wordpress they have started using simple scripts in place of fantastico (yes the install was a while ago). I followed the prompts and then got the dreaded error about finding some incompatibilities and asking permission to overwrite. I of course said no, but that stopped the process cold. I apparently had no option but to say yes.
But before I said yes (yes please overwrite files you aren’t telling me anything about …) I used filezilla to pull down a backup of all my files. Then, with some trepidation, I clicked yes to the overwrite prompt.
The first sign of trouble was that it gave me a new password for my admin account. Umm, I don’t use “admin” for my admin account. I then went to my blog and what was staring at me was the default wordpress theme with the single hello world post. Insert your favorite expletive here.
The lost of the theme wasn’t hugely concerning, that was easy to fix. And in fact I just went into the admin, switched themes to greyidea (the theme I’m using), with all my extensive customizations to it intact.
But none of the 100 or so blog posts. That seemed like a major problem, I hadn’t thought to back up the database (wordpress keeps a lot of stuff in a mySQL database). I would have rather rebuilt the theme.
But was all my posts gone? phpadmin is a most handy tool. And sure enough there were two databases. A peek at my saved wpconfig file showed I was pointing a different database. A quick fix (glad I saved the original config file so I had the username and password!) to wpconfig, upload, and I was back in business. Everything, even my original admin account started working again.
Installing sociable was easy compared to the “upgrade”.
So the question is, is there a easier way to upgrade wordpress to the latest version?