Echo produces double output of string.
-
<?php foreach((get_the_category()) as $childcat) { if (cat_is_ancestor_of(18, $childcat)) {echo $childcat->cat_name; } else {echo "No";} } ?>
Basically I want to test for the parent category of ID 18, any of its child categories are selected, if yes echo the name of child category, if no echo No.
When the child category is selected it’s fine- the child category is echoed. But when the child catgory is not selected, the echo is NoNo. Double output is produced by the code.
Is there anything wrong with the code above? Thank you.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Echo produces double output of string.’ is closed to new replies.