diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php
index eb6e185f5b49d..28678a66be258 100644
--- a/src/wp-includes/general-template.php
+++ b/src/wp-includes/general-template.php
@@ -1484,6 +1484,21 @@ function wp_get_document_title() {
$author = get_queried_object();
$title['title'] = $author->display_name;
+ /*
+ * If it's a weekly archive, use the week's date range as the title.
+ * Weekly archive links also contain the year, so check this before is_year().
+ */
+ } elseif ( is_date() && get_query_var( 'w' ) && get_the_date( 'Y-m-d' ) ) {
+ $week = get_weekstartend( get_the_date( 'Y-m-d' ), get_option( 'start_of_week' ) );
+ $date_format = get_option( 'date_format' );
+
+ $title['title'] = sprintf(
+ /* translators: 1: Week start date, 2: Week end date. */
+ _x( '%1$s – %2$s', 'weekly archives date range' ),
+ date_i18n( $date_format, $week['start'] ),
+ date_i18n( $date_format, $week['end'] )
+ );
+
// If it's a date archive, use the date as the title.
} elseif ( is_year() ) {
$title['title'] = get_the_date( _x( 'Y', 'yearly archives date format' ) );
@@ -2005,6 +2020,18 @@ function get_the_archive_title() {
} elseif ( is_author() ) {
$title = get_the_author();
$prefix = _x( 'Author:', 'author archive title prefix' );
+ } elseif ( is_date() && get_query_var( 'w' ) && get_the_date( 'Y-m-d' ) ) {
+ // Weekly archive links also contain the year, so check this before is_year().
+ $week = get_weekstartend( get_the_date( 'Y-m-d' ), get_option( 'start_of_week' ) );
+ $date_format = get_option( 'date_format' );
+
+ $title = sprintf(
+ /* translators: 1: Week start date, 2: Week end date. */
+ _x( '%1$s – %2$s', 'weekly archives date range' ),
+ date_i18n( $date_format, $week['start'] ),
+ date_i18n( $date_format, $week['end'] )
+ );
+ $prefix = _x( 'Week:', 'date archive title prefix' );
} elseif ( is_year() ) {
/* translators: See https://www.php.net/manual/datetime.format.php */
$title = get_the_date( _x( 'Y', 'yearly archives date format' ) );
diff --git a/tests/phpunit/tests/general/getTheArchiveTitle.php b/tests/phpunit/tests/general/getTheArchiveTitle.php
new file mode 100644
index 0000000000000..ed91cad5eb6c1
--- /dev/null
+++ b/tests/phpunit/tests/general/getTheArchiveTitle.php
@@ -0,0 +1,91 @@
+post->create(
+ array(
+ 'post_status' => 'publish',
+ 'post_date' => '2015-09-22 18:52:17',
+ )
+ );
+ }
+
+ public function set_up() {
+ parent::set_up();
+
+ update_option( 'start_of_week', 1 );
+ update_option( 'date_format', 'F j, Y' );
+ }
+
+ /**
+ * Tests that a weekly archive uses the week's date range, not the year.
+ *
+ * @ticket 66489
+ */
+ public function test_get_the_archive_title_on_weekly_archive() {
+ $this->go_to( '?m=2015&w=39' );
+
+ $this->assertTrue( is_year(), 'Weekly archive links also set is_year().' );
+ $this->assertSame( 'Week: September 21, 2015 – September 27, 2015', get_the_archive_title() );
+ }
+
+ /**
+ * Tests that a weekly archive respects the start_of_week option.
+ *
+ * @ticket 66489
+ */
+ public function test_get_the_archive_title_on_weekly_archive_respects_start_of_week() {
+ update_option( 'start_of_week', 0 );
+
+ $this->go_to( '?m=2015&w=38' );
+
+ $this->assertSame( 'Week: September 20, 2015 – September 26, 2015', get_the_archive_title() );
+ }
+
+ /**
+ * Tests that a weekly archive without the year uses the week's date range.
+ *
+ * @ticket 66489
+ */
+ public function test_get_the_archive_title_on_weekly_archive_without_year() {
+ $this->go_to( '?w=39' );
+
+ $this->assertSame( 'Week: September 21, 2015 – September 27, 2015', get_the_archive_title() );
+ }
+
+ /**
+ * @ticket 66489
+ */
+ public function test_get_the_archive_title_on_yearly_archive() {
+ $this->go_to( '?m=2015' );
+
+ $this->assertSame( 'Year: 2015', get_the_archive_title() );
+ }
+
+ /**
+ * @ticket 66489
+ */
+ public function test_get_the_archive_title_on_monthly_archive() {
+ $this->go_to( '?m=201509' );
+
+ $this->assertSame( 'Month: September 2015', get_the_archive_title() );
+ }
+
+ /**
+ * @ticket 66489
+ */
+ public function test_get_the_archive_title_on_daily_archive() {
+ $this->go_to( '?m=20150922' );
+
+ $this->assertSame( 'Day: September 22, 2015', get_the_archive_title() );
+ }
+}
diff --git a/tests/phpunit/tests/general/wpGetDocumentTitle.php b/tests/phpunit/tests/general/wpGetDocumentTitle.php
index df83ffbfc2de9..aa906dbff991d 100644
--- a/tests/phpunit/tests/general/wpGetDocumentTitle.php
+++ b/tests/phpunit/tests/general/wpGetDocumentTitle.php
@@ -240,6 +240,28 @@ public function test_day_title() {
$this->assertSame( sprintf( 'September 22, 2015 – %s', $this->blog_name ), wp_get_document_title() );
}
+ /**
+ * @ticket 66489
+ */
+ public function test_week_title() {
+ update_option( 'start_of_week', 1 );
+
+ $this->go_to( '?m=2015&w=39' );
+
+ $this->assertSame( sprintf( 'September 21, 2015 – September 27, 2015 – %s', $this->blog_name ), wp_get_document_title() );
+ }
+
+ /**
+ * @ticket 66489
+ */
+ public function test_week_title_without_year() {
+ update_option( 'start_of_week', 1 );
+
+ $this->go_to( '?w=39' );
+
+ $this->assertSame( sprintf( 'September 21, 2015 – September 27, 2015 – %s', $this->blog_name ), wp_get_document_title() );
+ }
+
public function test_404_title() {
$this->go_to( '?m=404' );