微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何从WooCommerce评论部分删除comment-author- [USER-ID]类?

如何解决如何从WooCommerce评论部分删除comment-author- [USER-ID]类?

有人知道如何从woocommerce评论部分删除突出显示的课程吗?

enter image description here

解决方法

可以使用WordPress comment-author-[USER-ID]过滤器挂钩删除[USER-NICKNAME]comment_class类。

所以您得到:

/**
 * Filters the returned CSS classes for the current comment.
 *
 * @since 2.7.0
 *
 * @param string[]    $classes    An array of comment classes.
 * @param string      $class      A comma-separated list of additional classes added to the list.
 * @param int         $comment_id The comment ID.
 * @param WP_Comment  $comment    The comment object.
 * @param int|WP_Post $post_id    The post ID or WP_Post object.
 */
function filter_comment_class( $classes,$class,$comment_id,$comment,$post_id ) {
    // Loop through classes
    foreach ( $classes as $key => $class ) {
        // Check if a string contains a specific word
        if ( strpos( $class,'comment-author') !== false ) {
            // Unset a given variable
            unset( $classes[$key] );
        }   
    }
    
    return $classes;
}
add_filter( 'comment_class','filter_comment_class',10,5 );

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。