网站优化

网站优化

Products

当前位置:首页 > 网站优化 >

Wordpress - 更改“登录回复”URL

GG网络技术分享 2025-03-18 16:12 29


问题描述:

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>

网友观点:

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

}

标签:

提交需求或反馈

Demand feedback