Wordpress. Exclude children category


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



Copy this code and paste it in your HTML
  1. <?php
  2. #exclude children category
  3. $get_childs = get_categories('child_of='.$cat);
  4. $q_cat = "cat=$cat";
  5. foreach ($get_childs as $cat_child) {
  6. $q_cat .= ",-$cat_child->cat_ID";
  7. }
  8. $query = new WP_Query($q_cat);
  9. ?>

URL: pokrovskii.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.