Forums

in comments, how to turn off link if author didn't enter URL? (4 posts)

  1. davidt82
    Member
    Posted 2 years ago #

    For my comments I have a href set up around the authors name so it links directly to the site they entered in the URL part of the comment form, however, when someone doesn't enter an address, the name links back to the post/page you are already on. Is there some sort of function I can use to disable linking when the author has not entered a URL? THANKS!

  2. richarduk
    Member
    Posted 2 years ago #

    This any use?

    Haven't tried it when no url is entered

    <?php comment_author_link() ?> displays the name of the author as defined in Admin Panel / Users / Authors and Users or as entered into the author input field.

    The name of the author acts as a link to the author's website as defined in Admin Panel / Users / Authors and Users or as entered into the url (website address) input field.

    Note the rel='external nofollow'
    See: http://codex.wordpress.org/Template_Tags/comment_author_link

  3. davidt82
    Member
    Posted 2 years ago #

    ok - tried this, it still links all authors names, and in the case of this <?php comment_author_link(); ?> it links back to a page with that user name (ie: example.com/author)

    here is the code I have, if anyone has a suggestion, please let me know:

    <*a* href="<?php comment_author_link(); ?>" target="_blank"> <?php comment_author() ?> Says:</h4>

    the asterisks around the a are just to prevent this from turning into a link.

  4. richarduk
    Member
    Posted 2 years ago #

    comment_author_link should provide a link, no need to add the < a href

    Also, there was no closing tag to the link, but that might be because you only pasted part of it

    Check your view source to see what was outputted, this alone might be the problem

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags