Forums

[resolved] Hide Comment Autor URL link when none exists (5 posts)

  1. colindunn
    Member
    Posted 2 years ago #

    Hello everyone,

    I am guessing this is a pretty easy problem to solve, but being new to the wordpress game I am having a little trouble with it.

    What I want to have happen is when a commenter provides a URL, a link appears in the comment to the author's website. That's the easy part. The problem is that even if the commenter doesn't provide a URL, the link text appears, linking to "#" and providing no distinction between the commenters with websites and those without. Here is the code I am currently using:

    <?php comment_author_url_link('My Awesome Website'); ?>

    According to the documentation, this "Displays the comment author's URL (usually their web site), linked,if one was provided..." However it seems to instead be providing a link no matter if a URL exists or not.

    Does anyone have a fix for this?

  2. xdesi
    Member
    Posted 2 years ago #

    I haven't really used this before but something like this might work:

    <?php if(get_comment_author_url() != ""){ comment_author_url_link(); } ?>

  3. colindunn
    Member
    Posted 2 years ago #

    Works perfectly! Thanks so much

  4. venkatesh_bashetty
    Member
    Posted 1 year ago #

    I'm facing same problem, How to fix this ? Kindly can anyone explain, I'm new to wordpress

  5. venkatesh_bashetty
    Member
    Posted 1 year ago #

    How to Hide Comment Autor URL link when none exists

Topic Closed

This topic has been closed to new replies.

About this Topic