我正在尝试更改评论中“登录以回复链接”的 URL,如此图 v
我确实遇到了这段我认为会有所帮助的代码片段,但它似乎使链接完全消失了。
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;
}
}
我意识到我可能遗漏了一些非常明显的东西,因为我对 php 完全陌生,所以请保持温和。谢谢。
您找到的代码片段是删除链接以完全回复。您只想过滤函数以添加自定义措辞。您可以在此处了解有关 Wordpress 过滤器的更多信息
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' );
要更改 URL,您可以使用以下过滤器更改 wordpress 登录 URL
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
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句