Support » Fixing WordPress » comments_number cases help

  • Anonymous

    Hello, i’m currently using this code to display the number of comments under the post title as a link to the comments…

    <a href="<?php echo get_permalink() ?>#comments"><?php comments_number(Be first to comment, 1 comment so far, % comments so far );?>

    This works fine if there are comments, however if there are 0 comments then /#comments at the end of the permalink does nothing. In this case I would need /#leave-comment.

    Is it possible to write this into the code above so that the two different cases produce two different links? I tried…

    <?php comments_number(<a href="<?php echo get_permalink() ?>#leave-comment">Be first to comment, ...etc

    This didn’t work and not really knowing anything about php I don’t think I’m going to guess how to do this. Can anyone help?

  • The topic ‘comments_number cases help’ is closed to new replies.