How to exclude posts from children categories in WordPress

Posted by Zahlan on August 10, 2012

Hi, the default wordpress category template shows all the posts for this category and also all posts from the children categories, some times we need to only get the category posts and exclude all posts from the children categories, you can you the following code to do that without any plugins or hacking the wordpress core files.

Simply put this line of code before the posts loop in category template:

and put this line of code after the loop:

That’s it 🙂

7 thoughts on “How to exclude posts from children categories in WordPress

  1. Greetings! I see this is to some degree off-topic nonetheless I had to talk to. Does managing a well-established web site enjoy joining your downline require a number of operate? I’m fresh to actually blogging and site-building nonetheless I achieve create during my diary day by day. I’d desire to set up a blog site in order to share my favorite expertise combined with emotions over the internet. You should move the post for people who have any tips or strategies of modern aspiring bloggers. Thankyou!

    1. Genivaldo,Católicos fazem exatamente o contrário.Concedendo, só para argumentar, que católicos o fizessem, então a tua idéia é: ele xinga, então eu posso xingar também?Quer dizer, os erros alheios justificam os teus próprios, é isto mesmo que tu estás dizendo?Abraços, Jorge

    2. La Ragione non è una deaGiusto per chiarire: la ragione è uno strumento per conoscere il mondo. La si usa perché funziona ed è il migliore che abbiamo. Ma resta pur sempre uno strumento. Non si può venerare la ragione più di quanto si possa venerare una chiave inglese o un cacciavite.Salvo che il cacciavite sia sonico 🙂

    3. As my baby left home for college back in August I began to roll through my mind all the things that I may not have taught her. I worried about all the decisions she was going to have to make on her own. All those feeling of I wasn’t enough cam floodng over me. Thank you for the reminder that I won’t be perfect and I am not expected to be. He will fill in the holes.

  2. Nice blog here! Additionally your website rather a lot up fast! What web host are you the use of? Can I am getting your affiliate link on your host? I wish my site loaded up as quickly as yours lol

Leave a Reply

Your email address will not be published. Required fields are marked *