• I wish to remove, disable or hide the comment authors’ links to their sites from my home page. The WordPress plug-ins for this purpose I have found on this website do not seem compatible with WP 4.0. I have found all kinds of different codes on this website to enter in different files like functions.php and comment.php but am very reluctant to do it lest I break my website. Kindly let me know whether you can help me with very clear step-by-step instructions that you have tested on your own website. . Thank you very much.

Viewing 11 replies - 1 through 11 (of 11 total)
  • you will possibly need to edit either commments.php or functions.php of your theme.

    details will depend on your currently used theme
    – please post the name and download link of your theme.

    https://codex.www.ads-software.com/Forum_Welcome#Include_as_much_information_as_possible

    Thread Starter groucho43

    (@groucho7)

    The name of the theme is Twenty Twelve.
    Its download link is https://www.ads-software.com/themes/twentytwelve
    Thanks.

    are you referring to the links in the ‘recent comments’ widget on your front page?

    do you want to keep te comment authors’ names?

    Thread Starter groucho43

    (@groucho7)

    The answers are yes and yes, but I want to disable their links to their own sites.
    Thanks!

    start by backing-up your site; https://codex.www.ads-software.com/WordPress_Backups

    then create a child theme of Twenty Twelve;
    https://codex.www.ads-software.com/Child_Themes
    or download one from https://quirm.net/themes/twenty-twelve-child/

    you will need to re-create any previously done customizations for instance of the header and the menu.

    create a functions.php file in the child theme (if you downloaded the child theme, then it will already contain a functions.php which you will need to edit);

    in your own empty functions.php, add absolutely at the start (nothing before that):
    <?php

    (this line is already in the downloaded functions.php)

    then add:

    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;
    }

    if you have done everything right, then the comment author links to their websites should be gone from the ‘recent comments’ widget.

    Thread Starter groucho43

    (@groucho7)

    Many thanks, “alchymyth”. This looks like rocket science to me ?? I much prefer using plug-ins to code-editing PHP files. Is there a simple and easy WordPress plug-in for backing up my website, and another one for creating the child theme you suggest? And why is the child theme even necessary? Why not add the code above to the beginning of the functions.php file in my host’s cPanel File Manager? Thanks again.

    For your website backup, you can use this plugin:
    https://www.ads-software.com/plugins/duplicator/

    For the child theme, this is not difficult. /
    1) create a folder twentytwelve-child in wp-content/themes/
    2) create a file style.css in the twentytwelve-child folder and copy this at the top:
    /*
    Theme Name: Twenty Twelve Child
    */
    4) create a file function.php in the twentytwelve-child folder and add the snippet that alchymyth gave you.

    Finally, why a child theme ? It allows you to add your customizations while still being able to update your parent theme in the future. Otherwise, if you customize directly the original theme and if you decide to update this theme in the future, you will loose your customizations

    Thread Starter groucho43

    (@groucho7)

    Hello Julien. I can’t tell you how much I appreciate your clear, detailed, step-by-step instructions. However, I have done everything you and alchymyth have told me, and, unfortunately, as you can see on my website https://avner-falk.net the comment authors’ links to their own websites are still there in the “Recent comments” widget. You seem to know your stuff, so if you have any other ideas, I shall be more than happy to try them out. I can also call you if you have some free time and let me have your phone number by e-mailing me to [email moderated – the forum does not provide support via email] Thanks again.

    right now, the site is still using the parent theme Twenty Twelve;

    did you ever activate the child theme?

    or did you try the suggested filter code directly in functions.php of the Twenty Twelve theme?

    Thread Starter groucho43

    (@groucho7)

    I could not activate the child theme because the style.css file was missing the Template line and therefore that theme was shown as broken in the my Themes folder.

    I have inserted the Template line. Now, however, if I activate the child theme, the links to the comment authors’ sites are inactive, but they are still displayed as hyperlinks. Moreover, the child theme is lacking all the features of the parent theme. It seems I need to import those features using wp_enqueue_style but I don’t know where and how to do so. I would greatly appreciate your assistance to complete the solution.

    Thank you very much.

    Thread Starter groucho43

    (@groucho7)

    Hello again,

    I hope you are having a nice weekend.

    I am still patiently waiting to learn how to import the attributes of the parent theme (twentytwelve) into the child theme (twentytwelve-child). In the meantime I have run into an additional problem: how to make all the hyperlinks on my website blue. I have used all sorts of plug-ins and CSS codes that either did not solve the problem or created new ones. As I am a real novice to WordPress, any assistance you may care to provide will be very much appreciated, but please do not go out of your way to reply and. above all, enjoy your weekend.

    Thanks again.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Remove comment author's link’ is closed to new replies.