Search 
Search Forums:


 




Inline Comments not working if no comments

Reply to Post
UserPost

11:10 am
August 27, 2008


dan

Guest

http://corp.hive7.com/blog/ is the site I’m working on. The inline comments form works great when the post already has comments, but I need to link to the comment form when there are 0 links (rather than just displaying the static ‘0 Comments’). What am I missing here?

12:47 pm
October 14, 2008


BusyMom

Guest

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

  1. <?php global $post; /* put this somewhere near the top of the file, not in your post looping code */ ?>
  2. ... skip down to the end of your code processing before the per post processing "endwhile"
  3. <?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 */ ?>
  4. <div id="mainPostReadComments">
  5. <?php
  6. $theCommentCount = (int)$post->comment_count;
  7. if( $theCommentCount == "0" ) {
  8. do_action(awp_commentform_link);
  9. do_action(awp_commentform);
  10. }
  11. 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 */
  12. ?>
  13. </div>
  14. <?php do_action(awp_comments); /* this will post the link for viewing comments here, it won't show if there are no comments */
  15. } ?>
  16. ... the rest of your code to continue processing posts
  17. 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

Reply to Post


Reply to Topic: Inline Comments not working if no comments

Name (Required):

EMail (Required):

Website):

Guest URL (required)

Math Required!
What is the sum of: 1 + 10        (Required)

Topic Reply:


 

About the Anthology of Ideas forum

Currently Online:

5 Guests

Maximum Online: 33

Forums:

Groups: 2

Forums: 6

Topics: 214

Posts: 673

Members:

There are 1 members

There are 201 guests

Aaron has made 245 posts

Top Posters:

Administrator: Aaron