Skip to content

Custom path template loading fails when using overridden templates #1481

@rajaeinet

Description

@rajaeinet

Hi
We are experiencing loading errors when using template overrides for some pages!
I believe this issue is caused by functions such as tutor_load_template_from_custom_path(), which determine the target file path using the __DIR__ constant.
In such cases, if a template containing these functions (that rely on __DIR__) is overridden, the sub-template paths are resolved relative to the child theme template instead of the plugin directory. As a result, if the sub-template files are not also overridden, loading errors occur.

On the contrary, , when a template loaded using __DIR__ is overridden, the overridden template does not take effect. For example:
If the single-content-loader.php template is overridden, all associated templates—

  • single-lesson.php
  • single-assignment.php
  • single-preview-lesson.php
  • single-quiz.php

must also be copied into the child theme directory without any changes.

The following code demonstrates that single-content-loader.php is being loaded from the plugin's template directory rather than the child theme directory:

tutor_load_template_from_custom_path( __DIR__ . '/single-content-loader.php', array( 'context' => 'lesson' ), false );

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