Shortening the Display of Blog Categories

Anyone using either the default TwentyTen WordPress Theme, or any theme based on it, like our own Ninthlink.com theme is, might find this interesting. I noticed that David‘s post on The Essentials of Landing Page Conversion was posted under the categories of Nlk Tips, Web Design, Web Development, AND Web Marketing, and all that text was causing the “Posted…” area to display oddly. The default behavior from that theme is to display the Categories a Post is posted in via WordPress’s get_the_category_list function. Due to our longer category names, and the prime real estate of the “Categories:…” area, something had to be done.

By bypassing that that call to get_the_category_list with a function of our own, where I essentially gave nicknames to our categories, now a potential post posted under all six of our Nlk Culture, Nlk Tips, Press / News, Web Design, Web Development, AND Web Marketing ought to still fit within our 348px area…

function nlkCatCleanup($id) {
$nicer = array(3=>'Design', 4=>'Develop', 5=>'Market', 2104=>'Culture', 2105=>'Tips', 2106=>'Press/News');
$catsarr = get_the_category($id);
$oot = '';
for($i=0;$i0) $oot .= ', ';
$oot .= '<a rel="category tag" title="View all posts in '. $catsarr[$i]->name .'" href="'. get_category_link($catsarr[$i]->term_id) .'">'. $nicer[$catsarr[$i]->term_id] .'</a>';
}
return $oot;
}

Leave a Reply