wordpress in subcategory


/ Published in: PHP
Save to your folder(s)

wordpress in subcategory


Copy this code and paste it in your HTML
  1. <?php
  2. function is_subcategory ($id) {
  3. $in_subcategory = false;
  4. foreach( explode( "/", get_category_children($id) ) as $child_category ) {
  5. if( in_category($child_category) ) {
  6. $in_subcategory = true;
  7. }
  8. }
  9. return $in_subcategory;
  10. }
  11. ?>
  12. <?php if ( is_category(1) || is_subcategory(1) ) { ?>
  13. ....LOOP....
  14. <?php } ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.