title: Wordpress: is child of category function
body: <p>I I am looking for a function that merely returns true or false. The function would check if the category archive being queried is a child of a particular parent category. The function would look something like this (similar to the <code>is_category()</code> function):</p>
  
  <pre><code>if(is_child_of_category('3')){ //do something }
  if(is_child_of_category('4')){ //do something else }
  if(is_child_of_category('5')){ //do something entirely different }
  </code></pre>
  
  <p>I have looked through the documentation and the forums but have not found any solutions, any ideas if this has been done or how one would go about it?</p>
  
  <p>/////////////
  addendum
  ////////////</p>
  
  <p>Here is the working code that I wrote with help from Gavin:</p>
  
  <p>Thanks Gavin</p>
  
  <p>first a function for the functions.php file to get the category id:</p>
  
  <pre><code>function getCurrentCatID(){
  global $wp_query;
  if(is_category() || is_single()){
  $cat_ID = get_query_var('cat');
  }
  return $cat_ID;
  }
  </code></pre>
  
  <p>Next use <code>cat_is_ancestor_of</code></p>
  
  <pre><code>$post = $wp_query-&gt;post;
  $id = getCurrentCatID();
  </code></pre>
  
  <p>if ( cat_is_ancestor_of(3, $id) { include(TEMPLATEPATH . '/unique.php'); }</p>