子比主题 – 二开最近评论小工具样式

2025-11-29 0 994

轩玮博客演示图:

原版

子比主题 – 二开最近评论小工具样式

美化版:

子比主题 – 二开最近评论小工具样式

轩玮博客提供部署教程:

教程开始

首先进入网站目录中/wp-content/themes/zibll/inc/functions/zib-comments-list.php找到这个文件搜索zib_widget_comments函数名整段替换为下面的即可

[hidecontent type=”reply” desc=”隐藏内容:评论后查看”]

function zib_widget_comments($limit, $outpost, $outer)
{
    global $wpdb;
    $args = array(
        'orderby' => 'comment_date',
        'number'  => $limit,
        'status'  => 'approve',
        'post_type'=> ['post'],
    );

    if(_pz('bbs_s')){
        $args['post_type'][] = 'forum_post';
    }

    $author__not_in = preg_split("/,|,|\s|\n/", $outer);
    $post__not_in   = preg_split("/,|,|\s|\n/", $outpost);
    if ($author__not_in) {
        $args['author__not_in'] = $author__not_in;
    }
    if ($post__not_in) {
        $args['post__not_in'] = $post__not_in;
    }

    $comments = get_comments($args);

    $output = '';
    foreach ($comments as $comment) {
        $cont  = zib_comment_filters(get_comment_text($comment->comment_ID), 'noimg');
        $_link = get_comment_link($comment->comment_ID);
        $post_title = get_the_title($comment->comment_post_ID); // 获取文章标题
        $post_link = get_permalink($comment->comment_post_ID); // 获取文章链接
        $time      = zib_get_time_ago($comment->comment_date);
        $user_name = get_comment_author($comment->comment_ID);
        $user_id   = $comment->user_id;
        $c_like    = zib_get_comment_like('action action-comment-like pull-right muted-2-color', $comment->comment_ID);
        $vip_icon  = '';

        if ($user_id) {
            $user_name = '<a href="' . zib_get_user_home_url($user_id) . '" rel="external nofollow" >' . $user_name . '</a>';
            $user_name = zib_get_user_name('id=' . $user_id . '&level=0&class=inflex ac relative-h');
        }

        $avatar = zib_get_avatar_box($user_id);

        echo '<div class="posts-mini">';
        echo $avatar;
        echo '<div class="posts-mini-con em09 ml10 flex xx jsb mt10">';
        echo '<p class="flex jsb">';
        echo '<span class="flex1 flex">';
        echo $user_name;
        echo '<span class="flex0 icon-spot muted-3-color" title="' . $comment->comment_date . '">' . $time . '</span>';
        echo '</span>';

        echo '<span class="ml10 flex0">' . $c_like . '</span>';
        echo '</p>';
        echo '</div>';
        echo '</div>';
        echo '<div class="mx_comment">';
        echo '<a class="muted-color text-ellipsis-5 muted-box" style="margin:5px" href="' . $_link . '" rel="external nofollow" >' . $cont . '</a>';
        echo '<div class="comment-post-link" style="margin:5px; font-size:0.9em;">';
        echo '评论于:<a class="muted-2-color" href="' . $post_link . '" rel="external nofollow"  title="' . esc_attr($post_title) . '">' . $post_title . '</a>';
        echo '</div>';
        echo '</div>';
    }
}

 

[/hidecontent]

 

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

轩玮博客 子比主题 子比主题 – 二开最近评论小工具样式 http://blog.xuwbk.com/933.html

常见问题

相关文章

猜你喜欢
发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务