<?php
foreach (get_the_category() as $cat) {
$parent = get_category($cat->category_parent);
$parent_name = $parent->cat_name;
$parent_description = $parent->description;
echo '<div id="content_headline"><h1>'.$parent_name.'</h1></div>';
if (strlen($parent_description)>0) {
echo '<div id="content_main">'.$parent_description.'</div>';
}
}
?>
I use this code to display the parent cat and it's description.
The bit to check if there actually is a description does no work ... I get the DIVs no matter what.
Any ideas?
Syntax Terror
Member
Posted 4 months ago #
Mores,
The WordPress Codex mentions: "Note: if there is no category description, the function returns a br tag"
Perhaps you should compare if the value held is not empty, but holding this
?
Good luck!
teknoterror
Member
Posted 4 months ago #
I have checked and there is NO tag given, its simply empty, so I mores code will work now, perhaps it was fixed somewhere between version 2.6 and the current ver ;)
ps:excuse me for f*cking up my first account (above), this wordpress.org & .com business has be confused
You realise this thread is 8 months old right?