DevelopmentTips

Shortening the Display of Blog Categories

By October 26, 2010 No Comments

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;
}

Alex Chousmith

Alex has been building with Ninthlink since '06, and a San Diegan since the turn of the century. A background of Mathematics – Computer Science / Interdisciplinary Computing & Arts from UCSD, plus Drupal / WordPress / jQuery / CSS3 / HTML5 / bass guitar / homebrew skill, powers him to get the job done, no matter what.

Leave a Reply