开发者

How to apply different style to category navigation links in wordpress

I am开发者_如何学Python using wordpress 3.0. Is there any ways to apply different style class to category navigation. Eg: Consider we have three categories Audio,Video,Upload.Here I need to show Upload category in different style except other two. Thanks...


You could do it by adding a filter in your theme's functions.php:

function your_list_categories($categories){        
    $categories = preg_replace('Upload', '<span class="upload">Upload</span>', $categories);
    return $categories;
}
add_filter('wp_list_categories', 'your_list_categories');

If you have to do more complex processing, you could use get_categories() method and then loop through and build the output yourself:

function your_list_categories($categories){  

    $categories=  get_categories(); 
    $output = '';

    foreach ($categories as $category) {
        if($category->name == "Upload"){
             $output .= 'Category link code for Upload';
        } else {
             $output .= 'Category link code for all other category links';
        }
    }
    return $output;
}
add_filter('wp_list_categories', 'your_list_categories');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜