Alex has adopted the Thesis template for WordPress over on her blog, and I have to say they should be proud of what she’s done with it.

Thesis is a WordPress theming system that allows users to do a huge amount of customizing without having to do much or even any programming… but if they do want to crack open the nearest O’Reilly book, well, Thesis is happy to accommodate. And Thesis has recently added new feature that makes it dirt-easy to create an automatic dropdown menu from nested pages or nested categories. But what if you want to do something a little more ambitious?

Alex wanted to have a menu of selected categories, and have the titles of the three most recent posts in each category drop down when you roll over it.

Here’s the effect she’s going for (there’s still some styling work to do, but you get the idea):

So how did we do it? By inserting this snippet into the custom_functions.php file:

I owe a debt to gjchandler, who posted a code snippet I wound up adapting for the submenu.

While I do get to jump into PHP pretty regularly, it’s usually pretty linear, and I don’t often work with arrays and loops. So this was a lot of fun. And I’d love to hear if it works for you

(Just remember: unless you’re using Thesis version 1.6 or above, you’ll get the whole list in your menu for every category item, and kaboom goes your layout. Yikes!)

Mastodon