Admin panel > settings > catalog settings > find Catalog pages section and checked following setting.
Include products from subcategories
Thanks, but this will not solve my problem, as I mentioned I need this within the code, because I want to use only for one particular category template.