Can someone please shed some light into echoing html when it contains php functions? I am trying to echo out the following but cannot find a useful reference.
<a href="<?php comments_link(); ?>"><?php comments_number('<span class="nocomments">comments</span>', '<span class="onecomment">1 comment</span>', '<span class="morecomments">% comments</span>'); ?></a>
Grateful for any help!
Updated the code below, I hope I am making myself clear. If the comments don’t open/have been closed I am trying to echo out the else condition as text.
<?php
if ( comments_open() ) :
echo '<p>';
comments_popup_link( '<span class="one-comment">leave a comment</span>', '<span class="one-comment">1 comment</span>', '<span class="more-comments">% comments</span>', '');
echo '</p>';
else
echo
the following:
<a href="<?php comments_link(); ?>"><?php comments_number('<span class="zerocomments">comments</span>', '<span class="onecomment">1 comment</span>', '<span class="morecomments">% comments</span>'); ?></a>
The best way to echo HTML when it contains PHP functions is to break back out of PHP, as done above.
I’m not sure exactly what you’re trying to do, but the rest is up to you. 🙂