Body Classes for Styling WordPress Taxonomies

I recently noticed that WordPress does not seem to add style classes to the body tag for custom taxonomies in the same way that it does on category archives.

You can fix this by adding the following to your functions.php file.

function taxonomy_body_class( $classes ) {
	if ( is_tax() ) {
		$tax = get_query_var( 'taxonomy' );
		$term = $tax . '-' . get_query_var( 'term' );
		$classes = array_merge( $classes, array( 'taxonomy-archive', $tax, $term ) );
	return $classes;
add_filter( 'body_class', 'taxonomy_body_class' );

I don’t know why WordPress doesn’t do this automatically – I guess it should be added to core. What do you think?


Making your plugin meta boxes work with custom post types in WordPress 3.0

Getting to grips with custom post types in WordPress 3.0?

I am, and am finding they’re a great way to organise different content on your site and very easy to implement in just a few lines of code.

However, the challenge now is for plugin developers to make their plugins play nice with custom post types. The main thing I’ve noticed so far is that most plugins only tend to add meta boxes to posts and pages, so here’s the first step – getting your WordPress plugin meta boxes to work with custom post types.



Google Inline Jump To Links

It is now fairly common to see Google insert jump to anchor links for popular pages in their search results. For example, a search for “wordpress loop” returned 3 anchor links.

Inline Jump To Links

Then I did a search for “wordpress multiple loops” and noticed an additional jump to link within the description text.

Google has picked that section of the page as being more relevant to my search terms and has included a link to that anchor. Not only that but the description is taken from the page content immediately after that anchor point and heading. Clever.

Let’s look at the source code

In this example, looking at the page source code reveals an anchor tag followed by a heading tag followed by a paragraph of content.

<a name="Multiple_Loops_in_Action" id="Multiple_Loops_in_Action"></a>
<h4><span class="mw-headline">Multiple Loops in Action</span></h4>
<p>The best way to understand how to use multiple loops is to actually show an example of its use...

It’s unclear wether Google in picking the “Multiple Loops in Action” link text from the anchor name or the following heading text.

Interestingly the ‘mw-headline’ class applied to the heading seems to be a fairly standard class applied to headings in Wikis, so maybe this is what Google is picking up on.

I think I may have to try out some of this HTML markup and see what happens…

Further Reading


Category Paging Functions in WP e-Commerce 3.7.6

WP e-Commerce 3.7.6 now includes better support for paging on category pages.

The latest release contains a suite of functions (my little contribution) to help you customise how pagination is displayed in your WPSC templates.

You can find an in-depth look at these functions and how to use them in the WP e-Commerce Documentation.

Below are some quick examples of what you can do…