W3cubDocs

/WordPress

add_cssclass( string $class_to_add, string $classes ): string

Adds a CSS class to a string.

Parameters

$class_to_addstringrequired
The CSS class to add.
$classesstringrequired
The string to add the CSS class to.

Return

string The string with the CSS class added.

Source

function add_cssclass( $class_to_add, $classes ) {
	if ( empty( $classes ) ) {
		return $class_to_add;
	}

	return $classes . ' ' . $class_to_add;
}

Changelog

Version Description
2.7.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/add_cssclass