Thread Starter
andyb2
(@andyb2)
woops i guess i didn’t escape my characters
here it is again, kind of!
“><?php comment_author(); ?>
Thread Starter
andyb2
(@andyb2)
<a href="<?php comment_author_url(); ?>"><?php comment_author(); ?></a>
Thread Starter
andyb2
(@andyb2)
So i tried this piece of javascript
<script language="JavaScript" type="text/Javascript">
if (<?php comment_author_url(); ?> != null) {
document.write('<span class="commentauthor"> <a href="<?php comment_author_url(); ?>"><?php comment_author(); ?></a></span>');
} else {
document.write('<span class="commentauthor"> <?php comment_author(); ?></span>');
}
</script>
but i have now read that document.write is not supported un xhtml.
Any ideas what i could do??
cheers
if that works, and you are just worried about validation, just do this:
<script type="text/javascript">
<![CDATA[
// content of your Javascript goes here
]]>
</script>
Thread Starter
andyb2
(@andyb2)
i am not concerned with validation right now. The script above doesnt work.
All i am trying to do is hyperlink a commenters name if they leave a web site URL when making a comment. If they dont leave a url i just want to dosplay the name with no hyperlink.
The reason i am doing this is that i noticed that if you hyperlink all names with the url, then if the filed was left blank then the the default url is the name of the post. i dont want that!!
so i tried this php code, but it is giving me strange results:-
<?php
$urlentered = comment_author_url();
if (!empty($urlentered))
echo '<span class="commentauthor"><a href="',comment_author_url(),'" target="_blank">', comment_author(), ' </a></span>';
else
echo '<span class="commentauthor">', comment_author(), ' </span>';
?>
The strange result is that the url – when present- gets printed before the span tag.
I’ve been struggling with this for days now!!!
cheers
All i am trying to do is hyperlink a commenters name if they leave a web site URL when making a comment. If they dont leave a url i just want to dosplay the name with no hyperlink.
That’s what WP should do out of the box – without you messing with the code.
Then one should be ditched… closed…