Filter by Child / Parent Category

Use if statement found here that allows you to sort by the parent category, to show only relevant child categories on various landing pages:

// in category template, test if queried category is child of another category

if ( is_category() ) {

     $parent = 8;

     $categories = get_categories('include='.get_query_var('cat'));

     if ( $categories[0]->category_parent == $parent ) {

          echo 'category ' . $categories[0]->name . ' is a child of category ' . $parent;



Leave a Reply

Posted in php
katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.