Exclude children category from query

How to exclude children category from query:

<?php
   #exclude children category
   $get_childs = get_categories('child_of='.$cat);
   $q_cat = "cat=$cat";
   foreach ($get_childs as $cat_child) {
      $q_cat .= ",-$cat_child->cat_ID";
   }
   $query = new WP_Query($q_cat);
?>

Revisions

There are no revisions for this post.

Tags: , ,

No comments yet.

Leave a Reply