Viewing 2 replies - 1 through 2 (of 2 total)
  • Steve

    (@stevejohnson)

    Use a variation of what Mark posted in the other thread:

    function change_comment_classes( $classes ) {
    
    	// Classes is an array of class names, so for each item - $array_key => $class_name
    	foreach( $classes as $key => $class ) {
    		// Check the class name
    		switch( $class ) {
    			## if it's 'even' or 'odd', change
    			## if not, leave it alone
    			case 'even':
    				$classes[$key] = "bg1";
    				break;
    
    			case 'odd':
    				$classes[$key] = "bg2";
    				break;
    
    			default:
    				continue;
    		}
    	}
    	// Clean out the variables no longer needed
    	unset($key,$class);
    	// Return the result
    	return $classes;
    }
    add_filter( 'comment_class' , 'change_comment_classes' );

    Note that you don’t strictly have to use the ‘default’ case, but a lot of people like to see it for clarity.

    Thread Starter Danielx64

    (@danielx64)

    Hello,

    I just tried out your code, and it works ??

    Thankyou ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘the class names in comment_class()’ is closed to new replies.