OK, this drove me crazy for days while I learned enough about wordpress to come up with a simple fix / hack… In my case, my index page (for example, same for archives, etc), I wanted to post the view-comments function link when there are comments, but I wanted to post the add-comments function link when there are no comments. Very simple addition to my index.php (or archive.php, etc) code finally did the trick
<?php global $post; /* put this somewhere near the top of the file, not in your post looping code */ ?> ... skip down to the end of your code processing before the per post processing "endwhile" <?php if ( !is_feed() && !is_page() && !in_category( $skip_category ) && comments_open() ) { /* remember to declare $skip_category if you have a particular category that doesn't permit comments or else drop the test from the if statement */ ?> <div id="mainPostReadComments"> <?php $theCommentCount = (int)$post->comment_count; if( $theCommentCount == "0" ) { do_action(awp_commentform_link); do_action(awp_commentform); } else do_action(awp_comments_link); /* if there are comments, then activate the link for showing comments instead. This will not show if there are no comments anyway, but I liked the cleaner code */ ?> </div> <?php do_action(awp_comments); /* this will post the link for viewing comments here, it won't show if there are no comments */} ?> ... the rest of your code to continue processing posts - Use the following to copy and paste the code.
Remember to always back up your code before trying hacks so that you can easily return to the previous state. Use at your own risk!!
HTH Karen