category_link
category_link is a filter on the internal links generated for each category. It can pass two parameters. The first is the category link itself, and the second is the category's ID.
Context:
File: wp-includes/template-functions-category.php
function get_category_link($category_id) {
global $wp_rewrite;
$catlink = $wp_rewrite->get_category_permastruct();
if ( empty($catlink) ) {
$file = get_settings('home') . '/' . get_settings('blogfilename');
$catlink = $file . '?cat=' . $category_id;
} else {
$category = &get_category($category_id);
$category_nicename = $category->category_nicename;
if ($parent = $category->category_parent)
$category_nicename = get_category_parents($parent, false, '/', true) . $category_nicename . '/';
$catlink = str_replace('%category%', $category_nicename, $catlink);
$catlink = get_settings('home') . trailingslashit($catlink);
}
return apply_filters('category_link', $catlink, $category_id);
}
This hook can pass multiple parameters. In order to get additional parameters (up to 2 for this hook) passed to your function, you will have to hook in like this: add_filter('category_link', 'your_function', 10, 2); where 10 is your function's priority, and 2 is the number of parameters you want your function to accept. Note that your function should only return the first parameter.
This hook is a filter which means that information is passed through it, and then used by WordPress. Your function needs to accept that information, and return it. Using add_filter('category_link', 'your_function'); helps you to remember this distinction. When you are passing an ID, it is assumed that you will return the ID as it was given to you. With filters that pass strings or arrays, you may manipulate the information before passing it along.