wordpress if get_categories value larger/smaller -
i have code in category.php
<?php $getcatid = get_query_var('cat'); ?> <?php $args = array('child_of' => ''.$getcatid.'', 'parent' => ''.$getcatid.'', 'hide_empty' => 0);?> <?php $categories = get_categories($args); foreach ($categories $cat) { ?> <?php $getid = $cat->cat_id; ?> how check quantity subcategory value as:
if $categories < 4 ($getcatid had smaller 4 sub) echo code loop
else (if $categories > 4 ) echo code loop
any idea. thanks
if retrieve categories get_categories can run count() on result, check how many entries there are. can use number comparison.
probably (untested):
<?php // stripped code out $categories = get_categories($args); if(count($categories) > 4) { } else { } ?>
Comments
Post a Comment