[wp-trac] [WordPress Trac] #61352: PHP deprecation notice in wp_title()
WordPress Trac
noreply at wordpress.org
Sat Nov 1 22:12:53 UTC 2025
#61352: PHP deprecation notice in wp_title()
--------------------------+------------------------
Reporter: nexbridge | Owner: joedolson
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 6.9
Component: Themes | Version: 6.5.5
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
--------------------------+------------------------
Changes (by sabernhardt):
* keywords: has-patch commit => has-patch
Comment:
The `$title` variable is not always a string because `single_post_title()`
can return void. That is why the deprecation notice can show.
Another possibility is to check if `is_string( $title )` before running
`explode()` in `wp_title()`. After determining that the type is a string,
it could also check `'' !== $title` to skip the `explode()` function for
untitled posts.
----
Note: The `wp_get_document_title()` function, which is used by most themes
created in the last ten years instead of `wp_title()`, does not support a
post title of '0'. The 0 simply would not appear in the `<title>` tag. If
the slug is also `0`, then `example.org/0/` matches the `is_home()`
conditional and displays the blogroll instead of the desired post.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61352#comment:32>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list