Share Pastebin
Guest
Public paste!

fris

By: a guest | Mar 19th, 2010 | Syntax: None | Size: 0.56 KB | Hits: 94 | Expires: Never
Copy text to clipboard
  1. <?php
  2.  
  3. // functions.php file in your theme directory
  4.  
  5. // In wordpress no such function exists, only is_category(), with this you can take advantage of this incase you need to check for it.
  6.  
  7. function is_subcategory ($id) {
  8.     $in_subcategory = false;
  9.     foreach( explode( "/", get_category_children($id) ) as $child_category ) {
  10.         if( in_category($child_category) ) {
  11.             $in_subcategory = true;
  12.         }
  13.     }
  14.     return $in_subcategory;
  15. }
  16.  
  17. ?>
  18.  
  19. // theme code
  20.  
  21. <?php if ( is_category(1) || is_subcategory(1) ) { ?>
  22. <-- loop -->
  23. <?php } ?>