之前介绍过函数 comment_author_link,link 和 url 在这里的区别是:link是指 WordPress 站点中的作者页面-对应 author.php 模板文件。而 url 是指用户在评论文章时填写的站点地址。
如果 url 为空,则返回的数据和 get_comment_author 一致。
函数原型:
comment_author_url( int|WP_Comment $comment_id )
显示当前评论作者的URL。
$comment_id,WP_Comment或要打印作者IP地址的评论的ID。默认当前评论。
函数源码:
function comment_author_url( $comment_id = 0 ) {
$comment = get_comment( $comment_id );
$author_url = get_comment_author_url( $comment );
echo apply_filters( 'comment_url', $author_url, $comment->comment_ID );
}
使用举例:
<a href="<?php comment_author_url(); ?>">Visit <?php comment_author(); ?>'s site</a>
if ( get_comment_author() == get_comment_author_link() ) {
// 评论作者的url 是否存在
}
-
WordPress函数:translate_nooped_plural 翻译并注册字符串WordPress函数:translate_nooped_plural 翻译并注册字符串
-
WordPress函数:number_format_i18n 数字国际化WordPress函数:number_format_i18n 数字国际化
-
WordPress函数:date_i18n 日期国际化WordPress函数:date_i18n 日期国际化
-
WordPress函数:esc_html__ 转义HTML字符WordPress函数:esc_html__ 转义HTML字符
-
WordPress函数:esc_html_e 转义翻译的字符串并显示WordPress函数:esc_html_e 转义翻译的字符串并显示
-
WP Multilang WordPress翻译插件WP Multilang插件的主要功能是提供多语言支持,使用户能够创建多语言版本的网站,满足不同语言用户的需求。
暂无评论,抢个沙发...