Skip to content

Instantly share code, notes, and snippets.

@cameronjonesweb
Created May 10, 2017 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cameronjonesweb/13babbac98fb4ac7bbf156f6e9c3c740 to your computer and use it in GitHub Desktop.
Save cameronjonesweb/13babbac98fb4ac7bbf156f6e9c3c740 to your computer and use it in GitHub Desktop.
[WordPress] Set the page title for a 404 page and prevent the_title filter affecting menu items
<?php
function 404_page_title( $title, $id ) {
if( is_404() && !get_post_type( $id ) ) {
$title = 'Page not found';
}
return $title;
}
add_filter( 'the_title', 'fh_404_page_title', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment