Support » Fixing WordPress » if category description = empty …

  • Resolved mores


    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?

Viewing 1 replies (of 1 total)
  • 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!

Viewing 1 replies (of 1 total)
  • The topic ‘if category description = empty …’ is closed to new replies.