Take Complete Control Of Your WordPress Menu

I don’t normally post lists of plugins but for the first time ever my WordPress menu is completely controlled by WordPress itself in a smooth and efficient way. All thanks to some awesome plugins that you need to put in your WordPress management arsenal—right now. No more custom coding. No more hurried hacking when I change themes. Install these 3 plugins and stop worrying about your WordPress menu.

Continue reading

Customize Your Posts Without Touching Your Theme Files

I hate editing my WordPress theme files—and I’m a theme developer! It makes it a pain to update the theme when a new, better version comes out. And if you ever change your theme you’re either going to forget about some crucial edit you’ve made, or spend wasted hours hunting down all your customizations. Didn’t we decide to use WordPress because it was so simple to use?

Well, it is simple to use. The secret is to write a quick plugin. The really big secret is it’s not that hard.

Continue reading

Adding Class To The WordPress Page Menu

Problem: You need to add a class or id to the the unordered list in wp_page_menu. Maybe to implement some super-slick drop down page menus. But! That <ul> tag is trapped inside of wp_page_menu. What are you going to do?

Solution: Filter wp_page_menu. In the code example below we’ll use preg_replace to find the first—and only the first—<ul> tag and swap it out for <ul id="nav" class="something-classy">. Just drop this code snippet into your theme’s functions.php file and you’re set.

// Add ID and CLASS attributes to the first <ul> occurence in wp_page_menu
function add_menuclass( $ulclass ) {
  return preg_replace( '/<ul>/', '<ul id="nav" class="something-classy">', $ulclass, 1 );
}
add_filter( 'wp_page_menu', 'add_menuclass' );

How I Used A Custom Page Template To Redesign My Blog The Smart Way

The custom front page is a must for really taking control of your WordPress installation and using it to manage your website. Luckily, creating a custom front page is ridiculously easy. It’s something every WordPress tinkerer should tackle at least once.

Take a look at the custom front page I created for ThemeShaper. I’ll tell you exactly how I created it using a custom page template and even let you download the one I’m using here.

revenge-screenshot

Continue reading

Any WordPress Theme Can Be a Blank Framework

A question from a reader has prompted this post. What makes a WordPress Theme Framework? I say, any WordPress theme can be a theme framework.

I’m researching Thematic and would really like some clarification on child themes. You say several places to use a child theme but I couldn’t find a list — is Junction the only one? I’m very interested in your comment that “if you’re starting with a Child Theme any WordPress theme becomes a blank framework”. But how? Could you explain a bit? Maybe a step-by-step explanation? Do you install Thematic, then the child theme, then how does “any WordPress theme” come into play? Valerie

So is it true? Yep. I’ll tell you how, why and what it means. Continue reading

Collapsing WordPress Widget-Ready Areas & Sidebars

Problem: Theme users need as many widget-ready areas as possible. They’re easy to use and they help keep theme template files clean. But! unused, empty, widget-ready areas, areas waiting for you to add a widget of your choice, hang around waiting to spoil your designs by limiting your styling options. Just as bad, empty widget areas can invalidate your markup. But don’t worry, we can do something about it. Only first, we need to take a closer look at the problem.

Here’s how a typical widget-ready sidebar looks. I’ve taken the code from Automattic’s guide to widgetizing WordPress themes.

<ul id="sidebar">

 <!-- likely awesome stuff -->

</ul>

We’ve got an unordered list and inside of it a statement that looks for the dynamic_sidebar() function. If we’ve registered one, it’ll spit out our awesome stuff: WordPress widgets marked up as list items.

All very good. But what if we start out with no awesome stuff in there? No default widgets? Well, that means our containing ul element will be hanging out there in our site with no li elements in it. A list without list items. Totally invalid and totally unsemantic. Worse yet: what if you were styling that ul with a margin, border, or just positioning it? That styling would stick—even if the widget area was empty. Totally unacceptable.

Thankfully, there’s a fix. Continue reading

Custom WordPress Hooks and Filters in Thematic 0.6

Thematic version 0.6 is an upgrade I didn’t intend on making so quickly and there’s been some changes. Here’s a weird one: when every other WordPress theme author is desperately trying to add more and more settings to their theme options page, I took an option out. Even weirder: it made the theme better. How? I started adding custom hooks and filters to Thematic.

This is something I’ve wanted to get started on for a while so I’m glad it’s finally here.

Custom WordPress Hooks in Thematic 0.6

There are two new custom WordPress hooks in Thematic version 0.6: thematic_belowheader() and thematic_abovefooter(). You can find them in header.php and footer.php, respectively. I’m really excited about this small—but powerful—addition to Thematic. Almost anything you can think of can now be loaded into the theme, just below the header and just above the footer, by taking advantage of your Child Theme functions.php.

Now, I haven’t done anything exciting or creative with this yet—that I can show you—but here’s the outline of some functions that’ll get you started on taking advantage of the new hooks. Remember, these go in the functions.php of your Child Themes.

// Hook into the area below the header
function childtheme_helloworld() { ?>
     <h2>Hello World!</h2>
<?php }
add_action('thematic_belowheader','childtheme_helloworld');
// Hook into the area above the footer
function childtheme_goodbyeworld() { ?>
     <h2>Goodbye Cruel World!</h2>
<?php }
add_action('thematic_abovefooter','childtheme_goodbyeworld');

There you have it. That’s all you need to get started with the Thematic custom WordPress hooks. Fool around with it. Try it out with WordPress conditional tags. See what you can come up with.

Now for the filters. I think you’ll be impressed with the power filters give you over your theme. Continue reading

WordPress Theme Release Post Template

WordPress Theme Authors: In response to How to get featured in our Daily Releases on Weblog Tools Collection, I’ve made a template for posting your WordPress theme releases to the Weblog Tools Collection forum. Here it is for anyone that wants to use it. Enjoy.

<strong><a href="" title="Theme URL">Theme Name</a></strong>
License: license-type

Short description of the theme. Widget ready? Supports gravatars? Options page? One, two or three column theme? What colors is it available in? Is the header customizable?

<ul>
<li>Point one</li>
<li>Point two</li>
<li>Point three</li>
</ul>

<a href="" title="Theme Demo">Theme Demo</a> or <a href="" title="Theme Screenshot">Screenshot</a>

Feel free to use or adapt for your own theme releases.

How I used a WordPress Child Theme To Redesign My Blog

Problem: You want to take advantage of WordPress Parent-Child Themes but you want more control than is usually afforded through CSS alone. What about adding a Favicon? Or a link to a custom stylesheet for IE fixes.? Or editing the menu? How do you do that without messing around with the original Parent Theme?

Solution: You do what I did. I had this exact same problem redesigning ThemeShaper to take advantage of my WordPress Theme Framework, Thematic. I’ll tell you how I solved it and give you a better idea of the power of the functions.php file in WordPress Child Themes.

When you’re done reading this post you should be well on your way to taking full advantage of the power of WordPress Child Themes and redesigning your blog the smart way—leaving the original parent theme files untouched.

And if you haven’t heard about WordPress Child Themes before, make sure you take a look at my post on How To Protect Your WordPress Theme Against Upgrades. I go through a quick primer on them and how to get started using them (along with some useful tips on using Plugins).

First, Make a Functions.php File

Currently, only two overriding files are recognized in WordPress Child Themes, style.css and functions.php (unless my proposal for 2.7 makes it in). You can do a lot with CSS alone but with functions.php your theme can interact with WordPress just like a plugin.

First things first: make a file in your Child Theme folder called functions.php and add the PHP opening and closing tags to the first and second line (<?php and ?>) using your favorite text editor (I use Smultron). Make sure you don’t have any extra lines before or after these tags. We’re going to be inserting the following snippets of code on the lines in-between these tags. Now you’re ready to make your WordPress Child Theme sing.

… not literally, of course. That would be annoying. Continue reading

How To Protect Your WordPress Theme Against Upgrades

Problem: You’ve finally found a theme you like but you want to modify it. The modifications are pretty simple but what happens when you want to upgrade the theme? Do you really want to go through all those files again hunting down the changes? Don’t you wish you could just upgrade and be done with it?

I’ve been there. I’ve done everything the wrong way at least twice. Learn from my mistakes. Here’s the right way to modify your theme and protect it against any future upgrades. And don’t worry, it’s really simple. As it usually turns out, WordPress is ready for us and has done most of the heavy lifting.

Continue reading