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

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -