Support » Everything else WordPress » Linking to the #commentform

  • Hi there,
    I’m trying to include a link to the #commentsform. Here is what I have on my index.php

    <?php $comment_count = get_comment_count($post->ID); ?>
    <?php if ($comment_count['approved'] > 0) : ?> | <?php comments_popup_link(); ?> , what's your opinion!</a><?php endif; ?>

    Right now on my front page, next to the title, it shows nothing if there is no comments, and a # of comments if there are comments.
    What I want to do is the following:
    *If there is no comments, I want a link “What’s your opinion?” to the comment form of that post.
    *If there are comments, I want to show the number of comments and a link saying “What’s your opinion?” directly to the comment form.

    Now if I do this:

    <?php $comment_count = get_comment_count($post->ID); ?>
    <?php if ($comment_count['approved'] > 0) : ?> | <?php comments_popup_link(); ?> ,<a href="<?php comments_link(); ?>"> What\'s your opinion?</a><?php endif; ?>

    It works but the <?php comments_link(); ?> goes directly to the comments, and not to the comments form…which can sometimes be a long way to the bottom.

    There is probably a really simple solution to this but I just don’t see it yet.

Viewing 1 replies (of 1 total)
  • Figured it out.

    <?php $comment_count = get_comment_count($post->ID); ?>
    <?php if ($comment_count['approved'] > 0) : ?> | <?php comments_popup_link(); ?> , <a style="color:#0099cc;" href="<?php the_permalink(); ?>#commentform">what's your opinion?</a>
    <?php else : ?> | <a style="color:#0099cc" href="<?php the_permalink(); ?>#commentform"> Care to comment?</a><?php endif; ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Linking to the #commentform’ is closed to new replies.