Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Courses page throwing 404 in Hello Elementor theme #7683

Merged
merged 6 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/fix-archive-404-issue-in-hello-elementor
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Hello elementor theme throwing 404 when rendering the Courses archive page
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ protected function output_content_as_page( $content, $object_to_copy = null, $po
$wp_query->posts = array( $post );
// On taxonomy pages the queried_object must remain a WP_Term object.
if ( ! is_tax() ) {
$wp_query->queried_object = $post;
$wp_query->queried_object_id = $post->ID;
$wp_query->queried_object = $post;
}

$wp_the_query = $wp_query;
// phpcs:enable WordPress.WP.GlobalVariablesOverride.Prohibited

Expand All @@ -98,6 +98,7 @@ protected function output_content_as_page( $content, $object_to_copy = null, $po
$wp_query->is_404 = false;
$wp_query->is_page = true;
$wp_query->is_single = true;
$wp_query->is_singular = true;
$wp_query->is_archive = false;
$wp_query->max_num_pages = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ public function testCourseArchivePage_WhenRendered_RendersQueryListBlockIfPageCo
$this->assertStringContainsString( 'wp-block-sensei-lms-course-list', $post->post_content );
}

public function testHandleRequest_WhenCalled_SetsGlobalWpQueryWithCorrectIsSingularAndQueryObjectId() {
/* ARRANGE */
Sensei_Setup_Wizard::instance()->pages->create_pages();

/* ACT */
$this->handler->handle_request();

/* ASSERT */
$this->assertTrue( is_singular() );
$this->assertEquals( 0, get_queried_object_id() );
}

/**
* Helper to set up the current request to be a course archive page. This request
* will be handled by the unsupported theme handler if the theme is not
Expand Down
Loading