In your Avada’s child theme update your category.php, if its there or else
create new file with that name and add the code as below:
<?php
$current_cat = get_queried_object();
echo 'Heading: '.$current_cat->name;
$subcategories = get_categories(
array( 'parent' => $current_cat->term_id )
);
if(!empty($subcategories)){
foreach($subcategories as $cat){
echo '<br>'.$cat->name.'<br>';
$cat_posts = get_posts( array(
'posts_per_page' => -1,
'category' => $cat->term_id
) );
if ( $cat_posts ) {
foreach ( $cat_posts as $post ) :
echo $post->post_title.'<br>';
endforeach;
}
}
}else{
$cat_posts = get_posts( array(
'posts_per_page' => -1,
'category' => $current_cat->term_id
) );
if ( $cat_posts ) {
foreach ( $cat_posts as $post ) :
echo $post->post_title.'<br>';
endforeach;
}
}
It’ll print exactly as you asked for.
Update:
To get the posts as links, we can add tags like this:
Change everywhere:
echo $post->post_title.'<br>';
To:
echo '<a href="'.get_permalink().'">'.$post->post_title.'</a><br>';
It’ll make posts as links.