I want to add the comment count to the end of my post title. For example,
“13 Idea-Starters for Stuck Bloggers (23 comments)”
I currently have this code in the single.php file:
<h1><?php $title = the_title(); $commentcount = comments_number('0', '1', '%'); $fulltitle = $title . ' (' . $commentcount . ' comments)'; echo $fulltitle; ?></h1>
The post title displays momentarily but then is overwritten by the comment count. What am I doing wrong?
Thanks for your help.
- The topic ‘Add Comment Count to Post Title’ is closed to new replies.