makeitworkpress / wp-router

Enables developers to easily create custom routes with matching templates accordingly.
https://makeitwork.press/scripts/wp-router/
GNU General Public License v3.0
32 stars 6 forks source link

Unable to set template for root #2

Closed drewbaker closed 1 month ago

drewbaker commented 3 months ago

When visiting the home page, / this template doesn't work:

$router = new MakeitWorkPress\WP_Router\Router( 
    [
        'home'      => ['route' => ''],
        //'home'    => ['route' => '/'], // Both don't work
    ]
);

So how should we use the router to set a template for the home page?

Is this because a a theme requires index.php to work, which is the home page template? If so, would be good to add that gotcha to the readme.

leichim commented 3 months ago

Yes, I believe a theme requires an index.php to work indeed. WordPress defaults to this if nothing is load. There's a filter hook though in WordPress to adjust the default location were WordPress is looking.