Navigation List for Post Formats

Posted on

By Michael Fields

Post formats are a new feature that will be introduced in WordPress 3.1. I was hacking around with different formats this morning when I thought that it might be a good idea to create a secondary navigation element for the different formats. Here’s what I came up with.

/* Post Format Navigation. */
$formats = get_terms( 'post_format' );
if ( ! is_wp_error( $formats ) ) {
	print '<ul>' . "\n";
	foreach ( $formats as $format ) {
		$href = get_term_link( $format, 'post_format' );
		$text = get_post_format_string( str_replace( 'post-format-', '', $format->slug ) );
		print '<li><a href="' . $href . '">' . $text . '</a></li>' . "\n";
	}
	print '</ul>' . "\n";
}

The following code was tested in WordPress version 3.1 alpha, use at your own risk.

Share your thoughts

*

Fork me on GitHub