Site logo

Archived topic

How to translate the 404 page title tag "Nothing found"

3 replies · Started by Ingrid on December 3, 2020

Viewing posts 1–4 of 4

Hello!
I was wondering how can I change the text of the title tags of the "Nothing found" page, I want to change the title tag and NOT the text inside the page, since the text inside the page is already translated to my language.

It is showing correct then the user searches something and gets no results, but when the user visits a non existing pages the title tag shows like this:

<title>Nothing found for X</title>

Thanks in advance

Hi there,

you can use this PHP Snippet to change the title parts for your 404,

function theme_slug_filter_wp_title( $title_parts ) {
    if ( is_404() ) {
        $title_parts['title'] = 'ADD 404 TITLE TEXT HERE';
    }

    return $title_parts;
} 

// Hook into document_title_parts
add_filter( 'document_title_parts', 'theme_slug_filter_wp_title' );

great,thanks!

You're welcome

This archived topic is closed to new replies.