I’ve started optimizing tags, categories and custom taxonomies a lot more lately now that I can do all these neat things with them in my WordPress SEO plugin, and since I’m a busy guy I want to be able to do that quickly. So I wanted to edit my templates for those taxonomies to include an edit link. Looking through the WordPress source I could only find an edit_tag_link function, and I wanted it to work on custom taxonomies too. Turns out there’s nothing in core for that just yet.
Because I have to stay true to my own mentality expressed in another post: if you can fix it, do it, and submit a patch. So I made an edit_term_link function, created a patch and attached that to an already existing issue 9702 in the WordPress Trac that asked for something like that. We’ll see if it makes into core, I thought you might find it cool. My patch just got committed into core, so in WordPress 3.1, you’ll have edit_term_link and get_edit_term_link!
To be sure your site doesn’t die when you upgrade, I wrapped it in a if function_exists wrapper. You can just copy the code into your theme’s functions.php file, and then call edit_term_link() in your category, tag & taxonomy pages. Here’s the code:
if ( !function_exists('edit_term_link') ) {
function edit_term_link( $link = '', $before = '',
$after = '', $term = null ) {
if ( $term == null ) {
global $wp_query;
$term = $wp_query->get_queried_object();
}
$tax = get_taxonomy( $term->taxonomy );
if ( !current_user_can($tax->cap->edit_terms) )
return;
if ( empty($link) )
$link = __('Edit This');
$link = '<a href="' . get_edit_tag_link( $term->term_id,
$term->taxonomy ) . '" title="' . $link . '">' . $link . '</a>';
echo $before .
apply_filters( 'edit_term_link', $link, $term->term_id ) . $after;
}
}

I love the tech detail, but for new WP users and future coders like myself, could you include the answer to why this is important or how I use it?
Thanks, it would help me learn WP.
Derek
Simply add the following code on any category, tag or taxonomy template:
And if you’re logged in you’ll get an “Edit this” link, that takes you straight to that category, tags or taxonomy’s edit page :)
Awesome! this function exists with Drupal about time it existed with wordpress!
Good work Joost!
Awesome ! coolll
I agree – nice work Joost! I’ve just started to work with WP (I’ve been a Joomla fan for ages :-)) You are a great ressource – thanks!
Best regards,
Peer
I love the Tip, very usefull
Very nice! Thanks building code to work on custom taxonomies.
Great stuff Joost. Can you explain WHY you would want to optimise categories and tags? Also, by optimise do you mean simplify?