diff --git a/src/wp-content/themes/twentytwentyone/inc/template-functions.php b/src/wp-content/themes/twentytwentyone/inc/template-functions.php index 529564c295319..f141b99a8cf8f 100644 --- a/src/wp-content/themes/twentytwentyone/inc/template-functions.php +++ b/src/wp-content/themes/twentytwentyone/inc/template-functions.php @@ -182,12 +182,17 @@ function twenty_twenty_one_continue_reading_link() { * Adds a title to posts and pages that are missing titles. * * @since Twenty Twenty-One 1.0 + * @since Twenty Twenty-One 2.9 Only applies the filter on the front end. * * @param string $title The title. * @return string */ function twenty_twenty_one_post_title( $title ) { - return '' === $title ? esc_html_x( 'Untitled', 'Added to posts and pages that are missing titles', 'twentytwentyone' ) : $title; + if ( is_admin() ) { + return $title; + } + + return '' === $title ? esc_html_x( 'Untitled', 'Added on the front end to posts and pages that are missing titles', 'twentytwentyone' ) : $title; } } add_filter( 'the_title', 'twenty_twenty_one_post_title' ); diff --git a/tests/e2e/specs/dashboard.test.js b/tests/e2e/specs/dashboard.test.js index 9d290e58a9d50..0481d306f2e0b 100644 --- a/tests/e2e/specs/dashboard.test.js +++ b/tests/e2e/specs/dashboard.test.js @@ -149,11 +149,9 @@ test.describe( 'Quick Draft', () => { await saveDraftButton.click(); // Check that the new draft title appears in the 'Your Recent Drafts' section. - // This test relies on Twenty Twenty-One being the active theme. - // Twenty Twenty-One alters the default post title from "(no title)" to "Untitled". await expect( page.locator( '.drafts .draft-title' ).first().getByRole( 'link' ) - ).toHaveText( 'Untitled' ); + ).toHaveText( '(no title)' ); await expect( page.locator( '.drafts .draft-content' ).first() @@ -164,6 +162,6 @@ test.describe( 'Quick Draft', () => { await expect( page.locator( '.type-post.status-draft .title' ).first() - ).toContainText( 'Untitled' ); + ).toContainText( '(no title)' ); } ); } );