WordPress Show Parent Category Description for Sub-categories

Approach number one

If you are hard-coding a theme and you are writing your own category.php template, the first thing you have to do is to know what category you are displaying. You can use get_queried_object() to do that, which will return the current queried object.

$category = get_queried_object();

In your case you are calling the category.php template so it will return the queried category object.

The category object will be an instance of the WP term class. And as you can see in the docs, it contains the parent attribute.

$parent_cat_id = $category->parent;

Then, you can get the parent category description as follows:

$description = category_description($parent_cat_id);

See the docs for category_description()

Of course you will also have to check if the current category has a parent or not. You can do that with a simple if statement:

if($category->parent > 0){
$parent_cat_id = $category->parent;
}

Please note that by default, the parent attribute is set to 0. That means that if your value of $category->parent is equal to 0, that category does not have a parent. It is a primary category.

Approach number two

If you want to use filters, then you could use the category_description hook, which filters the category description for display.

Insert the following add_filter() call into your functions.php or custom plugin:

function wpse_display_parent_category_description($description, $category_id){

    $category = get_category($category_id);
    
    // Return the parent category description if it's a child category
    if($category->parent > 0){
    $parent_cat_id = $category->parent;
    return category_description($parent_cat_id);
    }

    // Or just return the original description if it's a primary category
    return $description;
}

add_filter('category_description', 'wpse_display_parent_category_description', 10, 2);