maybe with many ways, see
You can think of it as a decision tree. When WordPress tries to decide how to display a given page, it works its way down the template hierarchy until it finds the first template file that fits the requested page. For example, if somebody attempted to access the address https://yoursite.com/category/news, WordPress would look for the correct template file in this order:
category-{slug}.php: in this case category-news.php
we can create a category tempalte category-news.php, and put the PHP written in this and then invoke the PHP from url mysite/category/news
this can be also done if we make template with page-news.php and invoke the PHP from the url mysite/news
Then we must change the PHP commands with commands of WordPress PHP Framework, and possible create tables in the db.