如何将每个帖子标题显示为父类别 - 类别 - 在wordpress中发布内容?

First post, I really need some help with some PHP code for my wordpress site. I want to be able to display all post titles onsite in this format:

Category - Parent Category - Post Body

For example if a post was

Title: This is an example of a post title Body: SuperTest blah Category: Pepsi Parent Category: Drinks

The post Title would be displayed as

Pepsi - Drinks - SuperTest blah

Currently I've added the below code into the themes function.php file which is currently changing all post titles to show the category as the title, which is only 1/3 of what I want to do.

function your_title_cat( $title, $id = null ) {
    $category_detail = get_the_category($id);//$post->ID
    $cat = isset($category_detail[0])?$category_detail[0]:'';
    if($cat){
        return $cat->cat_name;
    }
    return $title;
}
add_filter( 'the_title', 'your_title_cat', 10, 2 );

How alterations would i need to do this? I'm a novice at Php. so please be patient with me. :)

Thanks!

I have modified you function to display parent category too:

function your_title_cat( $title, $id = null ) {
    if (!is_admin()) {
        $title = get_the_category_list( ' > ', 'multiple', $id) . ' > ' . $title;
    }
    return $title;
}
add_filter( 'the_title', 'your_title_cat', 10, 2 );