How to properly use add_rewrite_ rule (or tags) for page template?

[ad_1]

I have created a PHP template file called mypage.php and it is accessible at site.com/mycoolpage

As I am working with data I am hoping to learn how to accomplish this:

site.com/mycoolpage -> How to determine it is the main plugin page and no variables or path are submitted?

site.com/mycoolpage/things -> This should rewrite to site.com/mycoolpage?page=things

site.com/mycoolpage/things/add -> site.com/mycoolpage?page=add_things

site.com/mycoolpage/add -> invalid, treat as if it were main page

site.com/mycoolpage/stuff -> site.com/mycoolpage/?page=stuff

site.com/mycoolpage/stuff/add?id=42 -> site.com/mycoolpage?page=add_stuff&id=42

I’ve read about rewrite rules, rewrite tags, and query vars, but I keep going down rabbit holes trying to accomplish this. Any help appreciated!

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer