web建站教程
  1. 首页
  2. vuejs
  3. js
  4. 好玩
  5. seo教程
  6. 前端知识
  7. 百度echarts
  8. 更多
    php入门
    nodejs
    mockjs
    reactjs
    mysql
    wordpress
    织梦cms
    帝国cms
    git教程
    IT知识
    模板大全
    休息站

wordpress建站技巧如何根据评论回复状态显示文本

282 ℃
     

wordpress建站中,如何利用comment_form_title函数根据评论回复状态显示文本,下面web建站小编给大家简单介绍一下!

函数原型:

comment_form_title( string|false $no_reply_text = false, string|false $reply_text = false, bool $link_to_parent = true, int|WP_Post|null $post = null )

参数说明:

参数名 描述
$no_reply_text 不回复评论时要显示的文本。
$reply_text 回复评论时要显示的文本。接受“%s”作为回复评论的作者。
$link_to_parent 布尔值,用于控制将作者的姓名作为其评论的链接。
$post 显示评论表单的帖子。默认为当前全局职位。

函数源码:

function comment_form_title( $no_reply_text = false, $reply_text = false, $link_to_parent = true, $post = null ) {
  global $comment;

  if ( false === $no_reply_text ) {
    $no_reply_text = __( 'Leave a Reply' );
  }

  if ( false === $reply_text ) {
    $reply_text = __( 'Leave a Reply to %s' );
  }

  $post = get_post( $post );
  if ( ! $post ) {
    echo $no_reply_text;
    return;
  }

  $reply_to_id = _get_comment_reply_id( $post->ID );

  if ( 0 === $reply_to_id ) {
    echo $no_reply_text;
    return;
  }

  $comment = get_comment( $reply_to_id );

  if ( $link_to_parent ) {
    $author = '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author( $reply_to_id ) . '</a>';
  } else {
    $author = get_comment_author( $reply_to_id );
  }

  printf( $reply_text, $author );
}

调用方法:

<h3><?php comment_form_title(); ?></h3>
<h3><?php comment_form_title( __( 'Leave a Reply', 'textdomain' ), __( 'Leave a Reply to %s', 'textdomain' ) ); ?></h3>

WordPress如何判断当前文章是否是密码保护文章

WordPress版本如何使用str_starts_with和str_ends_with函数

WordPress如何显示当前文章的评论个数

wordpress如何显示下个评论链接

wordpress教程如何输出用于回复评论的隐藏输入html

标签: comment_form_title, wordpress函数

上面是“wordpress建站技巧如何根据评论回复状态显示文本”的全面内容,想了解更多关于 wordpress 内容,请继续关注web建站教程。

当前网址:https://ipkd.cn/webs_4793.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

当前位置: 网站首页 > wordpress
本文共计1106个字,预计阅读时长8分钟
生活小工具,收录了80多款小工具
上一篇: 阿里巴巴普惠体3.0字体已经更新(最强中文字体)
下一篇: 跨平台划词翻译、截图翻译工具——Pot划词翻译
x 打工人ai神器