I've got a custom post type with a standard tag taxonomy added to it like so: 'taxonomies' => array('post_tag'). I've added some tags to some posts of this CPT which are display on the front-end with the template tag the_tags() and the links it generates have this format http://local.mysite.dev/tag/tag1/. When I click such a link a page without any posts is generated using the tag.php template, but if I add ?post_type=seron_mycpt to the end of the URL like so http://local.mysite.dev/tag/tag1/?post_type=seron_mycpt a page with the relevant posts is generated using the same template but this time I also get these lines added to debug.log:
PHP Notice: Undefined property: stdClass::$labels in /...sitepath.../wp-includes/general-template.php on line 665
PHP Notice: Trying to get property of non-object in /...sitepath.../wp-includes/general-template.php on line 665
These notices are produced when wp_title() is called in the header.php template. According to the rewrite rules the request is transformed into the query tag=tag1&post_type=seron_mycpt.
For debugging I put print_r(get_queried_object()); in header.php and got this:
MYSITEstdClass Object
(
[term_id] => 27
[name] => tag1
[slug] => tag1
[term_group] => 0
[term_taxonomy_id] => 27
[taxonomy] => post_tag
[description] =>
[parent] => 0
[count] => 2
)
I think WP expects a CPT object with a labels property but gets this object instead which doesn't have that property.
If I tag an ordinary post with the same tag, the same header.php and tag.php templates are used and that post is displayed when using the http://local.mysite.dev/tag/tag1/ URL, and in that case no PHP notices are produced in debug.log, although print_r(get_queried_object()) shows a very similar object. Maybe WP never reaches the notice-producing line in general-template.php.
I don't understand what this object is and why it is passed instead of a CPT object. Could someone explain?
