Skip to content

Custom course templates override lesson and quiz templates #636

Description

@mauropereiira

Description

When a custom block template is assigned to an individual LearnPress course, lesson and quiz URLs render the course overview instead of the course item. LearnPress still adds its course-item-popup body class, which disables normal page scrolling.

This reproduces with LearnPress 4.4.4 and WordPress 7.0.3 under both Assembler 0.0.29 and Twenty Twenty-Five 1.5. Editing LearnPress's supplied Single Course template works; assigning a separate custom template to the course triggers the problem.

Steps to reproduce

  1. Activate LearnPress 4.4.4 with a block theme.
  2. Create a published course containing a lesson or quiz.
  3. Create a custom block template containing the normal Single Course blocks.
  4. Assign that custom template to the course.
  5. Open the course and select its lesson or quiz.

Expected

The lesson, quiz, or protected-content notice appears inside LearnPress's course item layout.

Actual

The URL changes to the lesson or quiz URL, but the custom course overview renders again. The body has course-item-popup and overflow-y: hidden, while the expected #popup-course element is absent.

Cause

WordPress places the course's assigned _wp_page_template first in the single-template hierarchy. GutenbergHandleMain::set_blocks_template() appends SingleCourseItemBlockTemplate but leaves the higher-priority course template in the candidate list, so WordPress selects the overview template.

Test matrix

Theme Assigned course template Result
Assembler 0.0.29 Default Course item works
Assembler 0.0.29 Custom Course overview reloads; page cannot scroll
Twenty Twenty-Five 1.5 Default Course item works
Twenty Twenty-Five 1.5 Custom Course overview reloads; page cannot scroll

The same results occur for logged-in and logged-out requests.

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