Tag page resulting in `get_comments_number()` notice
-
When visiting a tag page (/events/tags/foo/), EM fakes a WordPress post in order to load within the theme template. See
EM_Tag_Taxonomy::template()
. Manually modifying$wp_query->queried_object
and$wp_query->post
is of questionable wisdom, though I understand why it’s being done 🙂 Anyway, the post object is not being filled in completely. In particular,$wp_query->post->comment_count
is empty, which means that any theme usingget_comments_number()
in the comments template (pretty standard practice – see twentytwelve for an example) will throw a PHP notice because an empty string, rather than a float, is being passed tonumber_format()
vianumber_format_i18n()
.Barring a rethink of the
$wp_query->post
strategy 🙂 I think the following will fix the immediate problem:$wp_query->post->comment_count = 0;
On the client site where I’m seeing the error, I’m doing the following as a temporary (though harmless) fix:
add_filter( 'get_comments_number', 'intval' );
- The topic ‘Tag page resulting in `get_comments_number()` notice’ is closed to new replies.