add_cssclass() WordPress Function

The add_cssclass() function allows you to add a custom CSS class to any Wordpress element. This is useful for customizing the look and feel of your site without having to edit the theme's CSS file. To use this function, simply add the following code to your theme's functions.php file:

add_cssclass( string $class_to_add, string $classes ) #

Adds a CSS class to a string.


Parameters

$class_to_add

(string)(Required)The CSS class to add.

$classes

(string)(Required)The string to add the CSS class to.


Top ↑

Return

(string) The string with the CSS class added.


Top ↑

Source

File: wp-admin/includes/menu.php

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

	return $classes . ' ' . $class_to_add;
}


Top ↑

Changelog

Changelog
VersionDescription
2.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.