wordpress小工具最新评论显示评论内容

2023-08-27 4723阅读 0评论
Kdatacenter:$17.1/月/1G内存/100GB SSD空间/1TB流量/1Gbps端口/KVM/韩国SK/直连;原生IP

wordpress默认的侧边栏有个 最新评论 小工具,其默认不显示评论内容,下面是修改后可以显示评论作者和评论内容的。
修改文件:wp-includes/default-widgets.php
找到:

if ( $comments ) {
	// Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
	$post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) );
	_prime_post_caches( $post_ids, strpos( get_option( 'permalink_structure' ), '%category%' ), false );
	foreach ( (array) $comments as $comment) {
		$output .=  '
  • ' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), 'comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '') . '
  • '; } }

    改为:

    wordpress小工具最新评论显示评论内容 第1张
    (图片来源网络,侵删)

    if ( $comments ) {
    foreach ( (array) $comments as $comment) {
    $output .= ‘

  • ’ . /* translators: comments widget:
    1: comment author, 2: post link */ sprintf(_x(‘%1$s : %2$s’, ‘widgets’),
    get_comment_author_link(), ‘comment_ID) ) . ‘”>’ . mb_strimwidth(strip_tags($comment->comment_content),0,46,”,’utf-8′) . ‘’) . ‘
  • ’;
    }
    }

    显示效果如下:


    免责声明
    1、本网站属于个人的非赢利性网站,转载的文章遵循原作者的版权声明。
    2、本网站转载文章仅为传播更多信息之目的,凡在本网站出现的信息,均仅供参考。本网站将尽力确保所
    提供信息的准确性及可靠性,但不保证信息的正确性和完整性,且不对因信息的不正确或遗漏导致的任何
    损失或损害承担责任。
    3、任何透过本网站网页而链接及得到的资讯、产品及服务,本网站概不负责,亦不负任何法律责任。
    4、本网站所刊发、转载的文章,其版权均归原作者所有,如其他媒体、网站或个人从本网下载使用,请在
    转载有关文章时务必尊重该文章的著作权,保留本网注明的“稿件来源”,并白负版权等法律责任。

    手机扫描二维码访问

    文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。

    发表评论

    快捷回复: 表情:
    评论列表 (暂无评论,4723人围观)

    还没有评论,来说两句吧...

    目录[+]