dongqiao1964 2019-02-15 12:53
浏览 141
已采纳

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.

</div>
  • 写回答

1条回答 默认 最新

  • 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

    add_filter('login_url','custom_login_url');
    
    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
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 CATIA有些零件打开直接单机确定终止
  • ¥15 请问有会的吗,用MATLAB做
  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并—
  • ¥15 ARIMA模型时间序列预测用pathon解决
  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序,怎么查看客户esp32板子上程序及烧录地址