henrywright
henrywright

Reputation: 10240

Why does WordPress automatically output a closing li or div tag at the end of each comment?

If you use WordPress you may have noticed the automatically included closing li or div tag at the end of each comment? Why does WordPress do this?Is this standard behaviour?

I don't see a reason for it as I have to now include an open li or div tag in my callback function.

See the wp_list_comments() function for background info: http://codex.wordpress.org/Function_Reference/wp_list_comments

Upvotes: 0

Views: 683

Answers (1)

shawncampbell
shawncampbell

Reputation: 938

WordPress automatically adds the closing </li> after listing "any children or whatnot" in order to accommodate nested replies. Otherwise, the list of nested replies would be a sibling to the original comment's list item, rather than a child of it.

The Comments Only With A Custom Comment Display section in the Codex for wp_list_comments() isn't very clear as it only states:

Note the lack of a trailing </li>. WordPress will add it itself once it's done listing any children and whatnot.

Upvotes: 3

Related Questions