1

I wish to remove the author's links to their original website, from my page

I know this is in either the functions.php or comments.php files.

I'm not sure exactly of how to edit these php files,

I've come across some code online that basically states that I must insert the following. But I am not sure where exactly to insert the curly brackets or normal brackets etc, so that the lines of code are implemented, and which brackets to use in this case.

Help please. I am new to Wordpress like less than 1 week old. So editing .php files is a bit daunting- but I am looking to learn how to do it successfully.

The website is www.nouvida.com--- I want the comment author's links not to be connected to the Original Theme's homepage..

add_filter( 'get_comment_author_link', 'remove_html_link_tag_from_comment_author_link' );

function remove_html_link_tag_from_comment_author_link ( $link ) {

    if( !in_the_loop() ) {
        $link = preg_replace('/<a href=[\",\'](.*?)[\",\']>(.*?)<\/a>/', "\\2", $link);
    }

    return $link;

}
  • Could you enlighten us a little more with what/where you meant to disable those links. Did you mean on all comments on the whole website where the author can comment or as Mark mentioned, or only on your home/front page. (* the code in my answer now is for the whole site*) – Charles Feb 18 '16 at 5:24
  • Currently when one clicks on the Comment Author's name e.g " Marco Perloc"- the link leads to the proteusthemes.com website. I want this link to be broken for the entire website. – Zoey Ndhlovu Feb 18 '16 at 14:42
  • See my answer, it takes care of this. – Charles Feb 18 '16 at 14:53
  • 1
    To stimulate other maybe even more detailed input from the community (so others also know if an answer(s) works), it would be nice to mark an answer as solved / or give a comment at least that it did not (yet) help/worked as wished. Please see how in the help center. – Charles Mar 4 '16 at 14:52
1

Add following code snippet in functions.php. (in your themefolder)

Edit new code:
- This should do the trick, sorry for the delay.

/**
 * Remove post author link on comments
 * 
 * @return string $author
 */
function wpse218025_remove_comment_author_link( $return, $author, $comment_ID ) {
    return $author;
}
add_filter( 'get_comment_author_link', 'wpse218025_remove_comment_author_link', 10, 3 );

Note: you can add functions almost always to your functions.php in your theme folder. Ofcourse is it also possible to make a plugin but that needs a little more coding.
Please take a look here for making your own plugin.

  • I think that she wants to remove it only from the home page.... – Mark Kaplun Feb 18 '16 at 5:05
  • @MarkKaplun , you could be absolutely right but then I probably don't understand what is wanted. (seeing no comment options on her home page, or I am blonde/blinde ..ugh) As soon she will respond and when needed I will edit of course the code with if( is_home etc. – Charles Feb 18 '16 at 5:13
  • Hey guys, Thanks for reverting so quickly, I would like to remove the Links in the "Comment Author's name"- currently their are linked to the homepage of the Theme's developers. But I wanted to remove these links altogether on the website. Secondly when the website is up and running, I would then like the "Comment Author's link to lead to the person's email details or FB account. – Zoey Ndhlovu Feb 18 '16 at 14:37
  • @ZoeyNdhlovu, first things first, the answer (that function) takes care for disabling comment authors link to their website. About point 2 in your comment, ehm "Your email address will not be published." means?! Last, the wish to link to their Facebook page is another "issue", you probably need to add a field to the comment form to achieve that. But that is another question. – Charles Feb 18 '16 at 15:16
  • @Charles, I used the above code snippet and inserted into the functions.php file, However it completely removed the "Author Name"- I would like to include the " Author name" but just break the link to the Website. Which means, If a User inserts a comment on my website, I still would like to see the Person's name. But then don't want to click their name- And then be sent to another destination out of the site... – Zoey Ndhlovu Feb 18 '16 at 17:28
-2

If I understand what do you want to make, paste this in your functions.php

function alter_comment_form_fields($fields){
    $fields['url'] = '';  //removes website field

    return $fields;
}

add_filter('comment_form_default_fields','alter_comment_form_fields');

This will remove the website field from the comments form.

If you don't want to display the link on authors comment, try to modify comments.php if it's present in your theme.

Hope it helps!

  • 1
    If I understand her question well and seeing her code she wants to remove the link an author name holds (only when filled out) as soon the author add a comment. – Charles Feb 18 '16 at 4:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.