Skip to content

Route using template not working  #902

@YassineBenaziz

Description

@YassineBenaziz
  • Themosis Version: 3.1.0
  • WordPress Version: 6.3.1
  • PHP Version: 8.1.12

Description

I'm trying to set a new route ( in my routes.php located in my theme, or in web.php route file located in PROJECT_ROUTE/routes/web.php ) using a custom template, but this is not working.

Steps to reproduce

Here is the content of my templates.php file :

return [
    'custom-template' => [__('Custom Template', THEME_TD), ['page']]
];

Then I go to the wordpress backoffice and I create a new page and with my custom-template model.

In my routes files I have set this :


Route::any('template', ['custom-template', 'uses' => 'PageController@custom']);

Route::any('/', 'HomeController@index');
Route::any('page', 'PageController@index');
.
.
.

When I try to access to my page with my custom template, It returns the view in the PageController@index instead of the one in PageController@custom.

And when i try log this in my controllers : $query->is_page_template() It returns false.

Expected behavior

I should get the view rendered from PageController@custom.

Thanks you .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions