Not sure if you found your answer but try:
if ( comments_open() ) :
echo '<p>';
comments_popup_link( '0', '1', '%', 'comments-link', '');
echo '</p>';
endif;
enable DEBUG to see any error messages;
http://codex.wordpress.org/Debugging_in_WordPress
right now, you are inserting html (that is the ) directly into php.
you don’t need the else part if it is not doing anything;
try to simplify the code to:
<?php if ( comments_open() ) { comments_popup_link( '0', '1', '%' ); } ?>
or correctly close and open the php tags like:
<?php if ( comments_open() ) { comments_popup_link( '0', '1', '%' ); } else { ?> <?php } ?>
(@dds_nl)
11 years, 1 month ago
I’m trying to add a tiny suffix to article titles, which would show the visitors how many comments a given article has. But, if the the comment section is closed, it gives me a big and nasty ‘comments closed’ remark. I don’t want that.
So I’ve tried my hand at PHP to disable this ‘comments closed’ remark. Here’s my code:
<?php if ( comments_open() ) { comments_popup_link( '0', '1', '%' ); } else { } ?>Except: it doesn’t work. It just refuses to load half the page if I enter this code. I’m really not sure how this php code is faulty, so I would be grateful if someone could point out to me what I did wrong.