[wp-trac] [WordPress Trac] #34516: wp_get_document_title() and post type archives by author

WordPress Trac noreply at wordpress.org
Fri Oct 30 23:21:41 UTC 2015


#34516: wp_get_document_title() and post type archives by author
--------------------------+-----------------------------
 Reporter:  greenshady    |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Previously, `wp_title()` ran a check when `is_author()` like so:

 {{{
 if ( is_author() && ! is_post_type_archive() ) {
         $author = get_queried_object();
         if ( $author ) {
                 $title = $author->display_name;
         }
 }
 }}}

 This made sense when viewing a post type archive by author like
 `example.com/?post_type=post_type&author=author_nicename`.

 However, `wp_get_document_title()` doesn't check this:

 {{{
 } elseif ( is_author() && $author = get_queried_object() ) {
         $title['title'] = $author->display_name;
 }}}

 The following notice is now given on post type archives by author:

 {{{
 Notice: Undefined property: stdClass::$display_name in C:\xampp\htdocs\wp-
 includes\general-template.php on line 875
 }}}

 This is because the queried object is actually the post type object rather
 than the author/user object.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34516>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list