Skip to content

Commit

Permalink
Merge pull request #7683 from Automattic/fix/archive-404-issue-in-hel…
Browse files Browse the repository at this point in the history
…lo-elementor

Fix Courses page throwing 404 in Hello Elementor theme
  • Loading branch information
donnapep authored Sep 13, 2024
2 parents ac2ab6b + 81a865a commit f634821
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
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

0 comments on commit f634821

Please sign in to comment.