2019-02-15 12:53
浏览 140

Wordpress - 更改“登录回复”URL

I am trying to change the URL for the "Log in to reply link" in my comments as shown in this image v

enter image description here

I did come across this snippet of code that i thought would help, but it just seems to make the link disappear altogether.

if ( ! function_exists( 't5_do_not_ask_for_comment_log_in' ) ) {

 add_filter( 'comment_reply_link', 't5_do_not_ask_for_comment_log_in' ); /** * Replaces the log-in link with an empty string. * * @param string $link * @return string */
 function t5_do_not_ask_for_comment_log_in( $link ) { 
     if ( empty ( $GLOBALS['user_ID'] ) && get_option( 'comment_registration' ) ) { 
         return ''; // add your link here 
        return $link; 



I realise that I am probably missing something really really obvious as I am completely new to php, so please be gentle. Thanks.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duan62819774
    duan62819774 2019-02-15 13:08

    The code snippet you found was to remove the link to reply entirely. You just want to filter the function in order to add custom wording. You can learn more about Wordpress filters here

    function change_comment_reply_text( $link ) {
        $link = str_replace( 'Log in to Reply', 'Change to This Text', $link );
        return $link;
    add_filter( 'comment_reply_link', 'change_comment_reply_text' );

    to change the URL you can change the wordpress login URL with the filter below

    function custom_login_url($login_url) {
      return home_url('/my-account/'); //change my-account to whatever the url slug is for the page you created
    点赞 评论