Fishy theme v0.8 unofficial released

August 16, 2010 | WP-fishy theme | 2 Comments »

There have been a lot of changes for publishing/updating themes on http://wordpress.org/extend/themes/ and it takes too long waiting for approval, so for now I’ll publish Fishy v.0.8 here.

Added Wordpress 3.0 features:

  • Background support
  • Custom header options
  • Wordpress custom menu
  • Updated menu position in theme options, added option “none”.
  • Added custom header image option for lower version.

P.S.
Before upgrading to fishy 0.8 please make a backup of existing fishy theme (if you made some modifications).

Link for download: Fishy v0.8

Multiple taxonomies in a dropdown menus

July 29, 2010 | Wordpress tutorials | 9 Comments »

There was a question how to make multiple custom taxonomies dropdown menu, for a comment it would be too long, so I wrote this tutorial.

Firstly you should read the first post regarding dropdown taxonomy:
http://www.aroundwp.com/display-custom-taxonomy-terms-in-a-dropdown-menu/

So now we must modify original code a little of jumpto.php file.

Original code

<?php
// Solution for displaying custom taxonomy terms in a dropdown menu.
function dropdown_tag($taxonomy, $args = '' ) {
	$defaults = array('taxonomy' => 'my_taxonomy', // <- write taxonomy name
		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
		'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
		'exclude' => '', 'include' => ''
	);
	$args = wp_parse_args( $args, $defaults );

	$terms = get_terms($taxonomy, array_merge($args, array('orderby' => 'count', 'order' => 'DESC')) );

	if ( empty($terms) )
		return;

	$return = generate_dropdown_tag( $terms, $taxonomy, $args );
	if ( is_wp_error( $return ) )
		return false;
	else
		echo apply_filters( 'dropdown_tag', $return, $args );
}

function generate_dropdown_tag( $terms, $taxonomy, $args = '' ) {
	global $wp_rewrite;
	$defaults = array(
		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
		'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC'
	);
	$args = wp_parse_args( $args, $defaults );
	extract($args);

	if ( !$terms )
		return;
	$counts = $term_links = array();
	foreach ( (array) $terms as $term ) {
		$counts[$term->name] = $term->count;
		$term_links[$term->name] = get_term_link( $term->name, $taxonomy );
		if ( is_wp_error( $term_links[$term->name] ) )
			return $term_links[$term->name];
		$term_ids[$term->name] = $term->term_id;
	}

	$min_count = min($counts);
	$spread = max($counts) - $min_count;
	if ( $spread <= 0 )
		$spread = 1;
	$font_spread = $largest - $smallest;
	if ( $font_spread <= 0 )
		$font_spread = 1;
	$font_step = $font_spread / $spread;

	// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
	if ( 'name' == $orderby )
		uksort($counts, 'strnatcasecmp');
	else
		asort($counts);

	if ( 'DESC' == $order )
		$counts = array_reverse( $counts, true );

	$a = array();

	$rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? ' rel="term"' : '';

	foreach ( $counts as $term => $count ) {
		$term_id = $term_ids[$term];
		$term_link = clean_url($term_links[$term]);
		$term = str_replace(' ', '&nbsp;', wp_specialchars( $term ));
		$a[] = "\t<option value='$term_link'>$term ($count)</option>";
	}

	switch ( $format ) :
	case 'array' :
		$return =& $a;
		break;
	case 'list' :
		$return = "<ul class='wp-tag-cloud'>\n\t<li>";
		$return .= join("</li>\n\t<li>", $a);
		$return .= "</li>\n</ul>\n";
		break;
	default :
		$return = join("\n", $a);
		break;
	endswitch;

	return apply_filters( 'generate_dropdown_tag', $return, $term, $args );
}
?>

Now in this code we have two functions dropdown_tag and generate_dropdown_tag.

Function dropdown_tag

function dropdown_tag($taxonomy, $args = '' ) {
	$defaults = array('taxonomy' => 'my_taxonomy', // <- write taxonomy name
		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
		'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
		'exclude' => '', 'include' => ''
	);
	$args = wp_parse_args( $args, $defaults );

	$terms = get_terms($taxonomy, array_merge($args, array('orderby' => 'count', 'order' => 'DESC')) );

	if ( empty($terms) )
		return;

	$return = generate_dropdown_tag( $terms, $taxonomy, $args );
	if ( is_wp_error( $return ) )
		return false;
	else
		echo apply_filters( 'dropdown_tag', $return, $args );
}

Function generate_dropdown_tag

function generate_dropdown_tag( $terms, $taxonomy, $args = '' ) {
	global $wp_rewrite;
	$defaults = array(
		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
		'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC'
	);
	$args = wp_parse_args( $args, $defaults );
	extract($args);

	if ( !$terms )
		return;
	$counts = $term_links = array();
	foreach ( (array) $terms as $term ) {
		$counts[$term->name] = $term->count;
		$term_links[$term->name] = get_term_link( $term->name, $taxonomy );
		if ( is_wp_error( $term_links[$term->name] ) )
			return $term_links[$term->name];
		$term_ids[$term->name] = $term->term_id;
	}

	$min_count = min($counts);
	$spread = max($counts) - $min_count;
	if ( $spread <= 0 )
		$spread = 1;
	$font_spread = $largest - $smallest;
	if ( $font_spread <= 0 )
		$font_spread = 1;
	$font_step = $font_spread / $spread;

	// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
	if ( 'name' == $orderby )
		uksort($counts, 'strnatcasecmp');
	else
		asort($counts);

	if ( 'DESC' == $order )
		$counts = array_reverse( $counts, true );

	$a = array();

	$rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? ' rel="term"' : '';

	foreach ( $counts as $term => $count ) {
		$term_id = $term_ids[$term];
		$term_link = clean_url($term_links[$term]);
		$term = str_replace(' ', '&nbsp;', wp_specialchars( $term ));
		$a[] = "\t<option value='$term_link'>$term ($count)</option>";
	}

	switch ( $format ) :
	case 'array' :
		$return =& $a;
		break;
	case 'list' :
		$return = "<ul class='wp-tag-cloud'>\n\t<li>";
		$return .= join("</li>\n\t<li>", $a);
		$return .= "</li>\n</ul>\n";
		break;
	default :
		$return = join("\n", $a);
		break;
	endswitch;

	return apply_filters( 'generate_dropdown_tag', $return, $term, $args );
}

To make it work with multiple custom taxonomies we need to clone dropdown_tag function and change it’s name in 2 places.

// First taxonomy
function dropdown_tag($taxonomy, $args = '' ) {
	$defaults = array('taxonomy' => 'first_tax', // <- write taxonomy name
		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
		'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
		'exclude' => '', 'include' => ''
	);
	$args = wp_parse_args( $args, $defaults );

	$terms = get_terms($taxonomy, array_merge($args, array('orderby' => 'count', 'order' => 'DESC')) );

	if ( empty($terms) )
		return;

	$return = generate_dropdown_tag( $terms, $taxonomy, $args );
	if ( is_wp_error( $return ) )
		return false;
	else
		echo apply_filters( 'dropdown_tag', $return, $args );
}

//Second taxonomy
function dropdown_tag_second($taxonomy, $args = '' ) {
	$defaults = array('taxonomy' => 'second_tax', // <- write taxonomy name
		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
		'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
		'exclude' => '', 'include' => ''
	);
	$args = wp_parse_args( $args, $defaults );

	$terms = get_terms($taxonomy, array_merge($args, array('orderby' => 'count', 'order' => 'DESC')) );

	if ( empty($terms) )
		return;

	$return = generate_dropdown_tag( $terms, $taxonomy, $args );
	if ( is_wp_error( $return ) )
		return false;
	else
		echo apply_filters( 'dropdown_tag_second', $return, $args );
}

As you can see for a second taxonomy I used function dropdown_tag_second name on 23 and 40 lines.


Final code of jumpto.php to support multiple taxonomies in a dropdown menus.

<?php
// First taxonomy
function dropdown_tag($taxonomy, $args = '' ) {
	$defaults = array('taxonomy' => 'first_tax', // <- write taxonomy name
		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
		'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
		'exclude' => '', 'include' => ''
	);
	$args = wp_parse_args( $args, $defaults );

	$terms = get_terms($taxonomy, array_merge($args, array('orderby' => 'count', 'order' => 'DESC')) );

	if ( empty($terms) )
		return;

	$return = generate_dropdown_tag( $terms, $taxonomy, $args );
	if ( is_wp_error( $return ) )
		return false;
	else
		echo apply_filters( 'dropdown_tag', $return, $args );
}

//Second taxonomy
function dropdown_tag_second($taxonomy, $args = '' ) {
	$defaults = array('taxonomy' => 'second_tax', // <- write taxonomy name
		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
		'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
		'exclude' => '', 'include' => ''
	);
	$args = wp_parse_args( $args, $defaults );

	$terms = get_terms($taxonomy, array_merge($args, array('orderby' => 'count', 'order' => 'DESC')) );

	if ( empty($terms) )
		return;

	$return = generate_dropdown_tag( $terms, $taxonomy, $args );
	if ( is_wp_error( $return ) )
		return false;
	else
		echo apply_filters( 'dropdown_tag_second', $return, $args );
}

function generate_dropdown_tag( $terms, $taxonomy, $args = '' ) {
	global $wp_rewrite;
	$defaults = array(
		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
		'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC'
	);
	$args = wp_parse_args( $args, $defaults );
	extract($args);

	if ( !$terms )
		return;
	$counts = $term_links = array();
	foreach ( (array) $terms as $term ) {
		$counts[$term->name] = $term->count;
		$term_links[$term->name] = get_term_link( $term->name, $taxonomy );
		if ( is_wp_error( $term_links[$term->name] ) )
			return $term_links[$term->name];
		$term_ids[$term->name] = $term->term_id;
	}

	$min_count = min($counts);
	$spread = max($counts) - $min_count;
	if ( $spread <= 0 )
		$spread = 1;
	$font_spread = $largest - $smallest;
	if ( $font_spread <= 0 )
		$font_spread = 1;
	$font_step = $font_spread / $spread;

	// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
	if ( 'name' == $orderby )
		uksort($counts, 'strnatcasecmp');
	else
		asort($counts);

	if ( 'DESC' == $order )
		$counts = array_reverse( $counts, true );

	$a = array();

	$rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? ' rel="term"' : '';

	foreach ( $counts as $term => $count ) {
		$term_id = $term_ids[$term];
		$term_link = clean_url($term_links[$term]);
		$term = str_replace(' ', '&nbsp;', wp_specialchars( $term ));
		$a[] = "\t<option value='$term_link'>$term ($count)</option>";
	}

	switch ( $format ) :
	case 'array' :
		$return =& $a;
		break;
	case 'list' :
		$return = "<ul class='wp-tag-cloud'>\n\t<li>";
		$return .= join("</li>\n\t<li>", $a);
		$return .= "</li>\n</ul>\n";
		break;
	default :
		$return = join("\n", $a);
		break;
	endswitch;

	return apply_filters( 'generate_dropdown_tag', $return, $term, $args );
}
?>

All modifications are done, now you can open for example sidebar.php and paste:

// First dropdown taxonomy
<select name="tag-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value="#">Select...</option>
<?php dropdown_tag('first_tax', 'number=0&order=asc'); ?>
</select>
// Second dropdown taxonomy
<select name="tag-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value="#">Select...</option>
<?php dropdown_tag_second('second_tax', 'number=0&order=asc'); ?>
</select>
p.s.
I think there is a better solution for multiple taxonomy dropdown, but this is my 5 cents.

Wordpress Fishy theme – how to use content slider

June 27, 2010 | WP-fishy theme | 5 Comments »

To enable content slider you must go to Appearance > Fishy options:

After you modified and saved Fishy options you can edit your posts to make them sticky:

If you check your website now, you should see sticky slider:

Now you can add picture to content slider using “Post Thumbnail” panel. You can find it below Categories panel in post edit window.

Edit options of picture (Best size of pictures is 340px x 180px). (There are many crop pictures online services, to resize your images.)

Thats all, now you can update your post and check website.
Final result:

Wordpress theme fishy v0.5

June 17, 2010 | WP-fishy theme | 7 Comments »

Fishy theme v0.5 was released some time ago so who are intrested there some features list:

  • Added pagenavi support
  • Added Theme options page
  • Position option for top menu
  • Postlinks auto shortening feature
  • Content slider from sticky posts option

I don’t know when I’ll update this theme next time, so if you have some problems or found some bugs please use forum, or write to me by mail. Now I am developing another wordpress theme, you will see it very soon :)

Wordpress 3.0 released

June 17, 2010 | Blog | No Comments »

Today (June 17, 2010), WordPress Version 3.0, named for Thelonious, was released to the public.

Features:

  • WordPress and WordPress MU have merged, allowing the management of multiple sites (called Multisite) from one WordPress installation.
  • New custom menu management feature, allows creation of custom menus combining posts, pages, categories, tags, and links for use in theme menus or widgets.
  • Improved Custom post types and custom taxonomies including hierarchical (category-style) support.

For these 3 features I was looking forward, work will go faster with less hacks ;)

So lets test together what wordpress big boys prepeared for us!

http://wordpress.org/download/

Wordpress custom taxonomy term description

June 7, 2010 | Wordpress tutorials | 2 Comments »

I was looking for a simple solution to make “sticky” posts in certain places like custom taxonomies or categories, but failed to find simple approach to the problem. Default feature “sticky posts” is good if we want sticky posts at the top of homepage, but it’s getting complicated if we want them in other places, so I started looking for another way around.
Then I remembered that tags and categories may have a description, that solved my problem, because I just needed some intro text about every custom taxonomy term (like mini profile).

To show category or tag description on your theme:

<?php echo category_description(); ?>
<?php echo tag_description(); ?>

You can use them like that for example:

In category.php

<?php
if ( category_description() !== '' ) { ?>
<div class="somestyle">
<?php echo category_description(); ?>
</div>
<?php } ?>

In taxonomy.php or tag.php

<?php
if ( tag_description() !== '' ) { ?>
<div class="somestyle">
<?php echo tag_description(); ?>
</div>
<?php } ?>

Code will check for descriptions and output them wraped in div, if they exist.

Search form with custom taxonomy terms and categories

June 4, 2010 | Wordpress tutorials | 7 Comments »

Today I’ll show you how to make custom search form, where you could select taxonomy term or category or maybe both.

Final result:

Firstly you should go to your themes directory and create new folder, for example lib. In lib folder create a file dropdown.php and paste code below:

<?php
// drop down menu for search
function dropdown_search($taxonomy, $args = '' ) {
	$defaults = array('taxonomy' => 'my_taxonomy', // <- write taxonomy name
		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
		'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
		'exclude' => '', 'include' => ''
	);
	$args = wp_parse_args( $args, $defaults );

	$terms = get_terms($taxonomy, array_merge($args, array('orderby' => 'count', 'order' => 'DESC')) ); // Always query top tags

	if ( empty($terms) )
		return;

	$return = generate_dropdown_search( $terms, $taxonomy, $args ); // Here's where those top tags get sorted according to $args
	if ( is_wp_error( $return ) )
		return false;
	else
		echo apply_filters( 'dropdown_search', $return, $args );
}

function generate_dropdown_search( $terms, $taxonomy, $args = '' ) {
	global $wp_rewrite;
	$defaults = array(
		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
		'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC'
	);
	$args = wp_parse_args( $args, $defaults );
	extract($args);

	if ( !$terms )
		return;
	$counts = $term_links = $term_slugs = array();
	foreach ( (array) $terms as $term ) {
		$counts[$term->name] = $term->count;
		$term_links[$term->name] = get_term_link( $term->name, $taxonomy );
		$term_slugs[$term->name] = $term->slug;
		if ( is_wp_error( $term_links[$term->name] ) )
			return $term_links[$term->name];
		$term_ids[$term->name] = $term->term_id;
	}

	$min_count = min($counts);
	$spread = max($counts) - $min_count;
	if ( $spread <= 0 )
		$spread = 1;
	$font_spread = $largest - $smallest;
	if ( $font_spread <= 0 )
		$font_spread = 1;
	$font_step = $font_spread / $spread;

	// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
	if ( 'name' == $orderby )
		uksort($counts, 'strnatcasecmp');
	else
		asort($counts);

	if ( 'DESC' == $order )
		$counts = array_reverse( $counts, true );

	$a = array();

	$rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? ' rel="term"' : '';

	foreach ( $counts as $term => $count ) {
		$term_id = $term_ids[$term];
		$term_link = clean_url($term_links[$term]);
		$term_slug = $term_slugs[$term];
		$term = str_replace(' ', '&nbsp;', wp_specialchars( $term ));
		$a[] = "\t<option value='$term_slug'>$term ($count)</option>";
	}

	switch ( $format ) :
	case 'array' :
		$return =& $a;
		break;
	case 'list' :
		$return = "<ul class='wp-tag-cloud'>\n\t<li>";
		$return .= join("</li>\n\t<li>", $a);
		$return .= "</li>\n</ul>\n";
		break;
	default :
		$return = join("\n", $a);
		break;
	endswitch;

	return apply_filters( 'generate_dropdown_search', $return, $term, $args );
}
?>

Edit line 4th and save.


Open functions.php file and write after opening php tag:

define('THEMELIB', TEMPLATEPATH . '/lib');

require_once(THEMELIB . '/dropdown.php');

Now you should create a new file in theme directory for example custom-search.php and paste code below:

<form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
<div class="alignleft">
<?php wp_dropdown_categories( 'show_option_all=Select...' ); ?>
<select name="taxonomy">
<option value="0">Select...</option>
<?php dropdown_search('my_taxonomy', 'number=0&order=asc'); ?>
</select>
</div>
<input type="text" value="<?php the_search_query(); ?>" name="s" id="s" class="searchinput" />
<input type="submit" id="searchsubmit" value="Search" class="btn" />
</form>

Finally you can call newly created search form like this:

<?php include (TEMPLATEPATH . '/custom-search.php'); ?>

Display custom taxonomy terms in a dropdown menu

June 3, 2010 | Wordpress tutorials | 8 Comments »


Sometimes I want to dislay my taxonomy terms in a different way, so today you will learn how to make a dropdown menu from custom taxonomy terms.

Firstly you should go to your theme directory and create new folder, for example lib. In lib folder create a file jumpto.php and paste code below:

<?php
// Solution for displaying custom taxonomy terms in a dropdown menu.
function dropdown_tag($taxonomy, $args = '' ) {
	$defaults = array('taxonomy' => 'my_taxonomy', // <- write taxonomy name
		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
		'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
		'exclude' => '', 'include' => ''
	);
	$args = wp_parse_args( $args, $defaults );

	$terms = get_terms($taxonomy, array_merge($args, array('orderby' => 'count', 'order' => 'DESC')) );

	if ( empty($terms) )
		return;

	$return = generate_dropdown_tag( $terms, $taxonomy, $args );
	if ( is_wp_error( $return ) )
		return false;
	else
		echo apply_filters( 'dropdown_tag', $return, $args );
}

function generate_dropdown_tag( $terms, $taxonomy, $args = '' ) {
	global $wp_rewrite;
	$defaults = array(
		'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
		'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC'
	);
	$args = wp_parse_args( $args, $defaults );
	extract($args);

	if ( !$terms )
		return;
	$counts = $term_links = array();
	foreach ( (array) $terms as $term ) {
		$counts[$term->name] = $term->count;
		$term_links[$term->name] = get_term_link( $term->name, $taxonomy );
		if ( is_wp_error( $term_links[$term->name] ) )
			return $term_links[$term->name];
		$term_ids[$term->name] = $term->term_id;
	}

	$min_count = min($counts);
	$spread = max($counts) - $min_count;
	if ( $spread <= 0 )
		$spread = 1;
	$font_spread = $largest - $smallest;
	if ( $font_spread <= 0 )
		$font_spread = 1;
	$font_step = $font_spread / $spread;

	// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
	if ( 'name' == $orderby )
		uksort($counts, 'strnatcasecmp');
	else
		asort($counts);

	if ( 'DESC' == $order )
		$counts = array_reverse( $counts, true );

	$a = array();

	$rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? ' rel="term"' : '';

	foreach ( $counts as $term => $count ) {
		$term_id = $term_ids[$term];
		$term_link = clean_url($term_links[$term]);
		$term = str_replace(' ', '&nbsp;', wp_specialchars( $term ));
		$a[] = "\t<option value='$term_link'>$term ($count)</option>";
	}

	switch ( $format ) :
	case 'array' :
		$return =& $a;
		break;
	case 'list' :
		$return = "<ul class='wp-tag-cloud'>\n\t<li>";
		$return .= join("</li>\n\t<li>", $a);
		$return .= "</li>\n</ul>\n";
		break;
	default :
		$return = join("\n", $a);
		break;
	endswitch;

	return apply_filters( 'generate_dropdown_tag', $return, $term, $args );
}
?>

Edit line 4th and save.


Now open functions.php file and write after opening php tag:

define('THEMELIB', TEMPLATEPATH . '/lib');

require_once(THEMELIB . '/jumpto.php');

All set :)
Go to your themes file for example sidebar.php and paste this code:

<select name="tag-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value="#">Select...</option>
<?php dropdown_tag('my_taxonomy', 'number=0&order=asc'); ?>
</select>

Edit 3rd line and save.


Thats all, now you have taxonomy terms in a drop down menu.

Wordpress custom taxonomies

June 2, 2010 | Wordpress tutorials | 9 Comments »

Wordpress custom taxonomy is a very powerful and useful feature, you can classify posts in many different ways, for example: movies, music, photos, artists, actors or anything else.
So how to create custom taxonomy? Well let’s look at the example below.
This code will register custom taxonomy:

<?php

//this code must be placed in functions.php file.

add_action( 'init', 'create_my_taxonomies', 0 );

function create_my_taxonomies() {
register_taxonomy( 'company', 'post', array( 'hierarchical' => false, 'label' => 'Company', 'query_var' => true, 'rewrite' => true ) );
register_taxonomy( 'my_taxonomy', 'post', array( 'hierarchical' => false, 'label' => 'My Taxonomy', 'query_var' => true, 'rewrite' => true ) );
}

?>
  • my_taxonomy – custom taxonomy name
  • My taxonomy – custom taxonomy label
  • hierarchical – can be used as true/false

False – non hierarchical tag type taxonomy, true – hierarchical category type taxonomy.
For now you must use “false”, because hierarchical custom taxonomies will be supported just in wordpress 3.0.

After you have made changes in functions.php file you can go to wordpress admin panel to check if everything works.

Custom taxonomy panels


Getting custom taxonomy terms on your page

Tagcloud

It’s very easy to make a tagcloud from taxonomy terms, just set the taxonomy argument.
You can place this code whatever you want.

<?php wp_tag_cloud( array( 'taxonomy' => 'my_taxonomy', 'number' => 45 ) ); ?>

List taxonomy terms for each post

<?php echo get_the_term_list( $post->ID, 'my_taxonomy', 'My Taxonomy: ', ', ', '' ); ?>

Custom taxonomy template hierarchy

  • taxonomy.php – for all custom taxonomies
  • taxonomy-{taxonomy-name}.php – template for some taxonomy
  • taxonomy-{taxonomy-name}-{term}.php – template for taxonomy term

Wordpress theme Fishy 0.3 update

April 27, 2010 | WP-fishy theme | No Comments »

Hello everyone,

Wordpress Fishy v.0.3 theme update released

From now on it will have Theme options page, to have more control over design.