carlynorama

the blog

WordPress Intermezzo – RobinRCutler.com

by Carlyn Maw on November 17, 2011, no comments

Or the answer to  – So Carlyn, what happened to the Drupal Series?

It is still going, but I had an “Wordpress Emergency” to attend to.  My mom has a website. She’s had it for a while but it has been neglected. I built it back in 2007 in WordPress. While WordPress was and is the best choice for this type of site,  it was a real hassle. WordPress has made a number of changes for the better in the past four years. The custom menu feature alone saved me hours and an hours of custom php scripting ( I swear I wrote a function called know_who_the_freakin_ancestor_is_already() )

What brings the big change on now is that she has a lot of material for her new project. Also, it is going to be winter in New York – well it IS winter in New York, and what goes better with a cup of tea and snow outside than blogging?  Also if I didn’t do it NOW… well things fall through the cracks, and she’s a good mom.

I modified the basic Twenty Eleven theme because that is really the one she liked. I was going to use Deilcate, but in the end I think she made a good call. Twenty Eleven is very well documented because it is the default.  NomNom I think, might also be a good choice to make a child theme from in the future maybe, but I couldn’t find it in the WordPress.org theme repository.

I’m not going to go through the whole set up, but there are some key modifications that took me a long time to wrestle with, so hopefully this will save someone else time some day. A couple of them could be full on tutorials, but I’ve got to get back to Drupal!

1. Make a child theme of twenty eleven
2. Turn comments on pages off
3. Change the position of the menu bar relative to the image.
4. Make the header image auto select itself depending on the post category.
5. Change how sticky posts display on Showcase home (move them down to recent posts)
6. Auto Create More Tags for Content going on the Front page. 
7. Put child pages of the Front page at the top of the showcase template

1. Make a child theme of twenty eleven

The first thing I wanted to do is screw with the colors, and I started here – 

The bad things bout this tutorial is only that the CSS it gives doesn’t have the gradients like the parent theme. By searching the style.css file of of 2011 for “#access”  you can copy and paste it’s code into your own css file and tweak the colors there.  Do that second, after you have seen that the orange example works so you know that your color scheme will in fact take.

2. Turn comments on pages off

To my mind, comments are for posts, not pages.  I moved a copy of page.php to my new child-theme directory and changed

<?php comments_template( ”, true ); ?>

to

<?php comments_template( ”, false ); ?>

3. Change the position of the menu bar relative to the image.

I wanted the menu bar ABOVE the image because one of my header images is taller than the others. I think it is better when the menu stays in the same place. I did it purely in CSS. This isn’t ideal because it makes the menu cover the image when the theme is scaled down, but it was taking me a long time to get it to work by changing the flow of the header.php, so I gave up and went with the CSS hack.  If I need to revisit this in the future I’ll take a look at how the NomNom theme puts it’s second bar above the header image. 

4. Make the header image auto select itself depending on the post category.

I didn’t want my mom to have to think about a special image for every post, and yet, as we go I want the images for different categories to be different. I created a directory in my child theme’s home directory called /images/headers and put images with names based on category slugs in there. This is not a good long term solution because it means Mom can ‘t change them herself.  (FTP isn’t her thing… yet) Some day I’ll look into adding a “pick image for category header” to the dashboard, but not this week!

5. Change how sticky posts display on Showcase home (move them down to recent posts area)

First there has to be a static front page and it has to have showcase.php as it’s template. There is a flaw in the directions for this in the Codex, I think. They say to call your new page for the front “Home,” but the is_home() function finds the blog home page and is_front() finds the real front page. Calling a page “Home” other than the one returned by the  is_home() function seems like a recipie for confusion, so I called mine Front instead.

I moved a copy of showcase.php to my child theme, took out all the code that it used for sticky posts and changed the recent posts section to be the following.

6. Auto Create More Tags for Content going on the Front page. 

The problem with the code above is that it dispalys the WHOLE post on the front page, which I don’t like since my mom is writing some pretty long pieces.   I was having a hard time getting the excerpt_length hook to work (resolved, ish) So I went around it and made it so if the post doesn’t have a more tag, I fake it.   I could have just insisted to Mom that she put More tags on all her posts, but she has enough she is trying to learn to remember to do each time to add that step too. 

7. Put child pages of the Front page at the top of the showcase template
Since I nuked the featured-posts section I wanted to adapt the concept of a highlighted area by using the children of the Front page as the content that shows on at the top of front page.

This is not perfected yet, but here is the code for starting off. It took me a tragically long time to trouble shoot this because as soon as I put anything that is a post related variable in my WP_Query it would return nothing. A flaw in WordPress’ behind the scenes is that the code (for good legacy reasons) some times uses the word “post”  (in function/variable names, etc) to mean JUST Posts and sometimes the word “post” is inclusive to mean Posts and Pages. Everything used to be a post, so it makes sense how it ended up that way, but it screwed me up writing the query, copying from examples that were about posts. 

Leave a Reply

carlynorama is Stephen Fry proof thanks to caching by WP Super Cache