问题描述
有人知道如何从woocommerce评论部分删除突出显示的课程吗?
解决方法
可以使用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 );