Add custom class inside body class function

Add custom class inside body class function

WordPress body class is a one of the very good feature. The classes keep changes according to the wordpress template.

So its good feature huh ? So how to Add custom class inside body class function ?
Its very easy. Just open the function.php and paste the below code.


add_filter( 'body_class', 'my_custom_classes' );
function my_class_names( $classes ) {
	// add 'class-name' to the $classes array
	$classes[] = 'wordpress';
	// return the $classes array
	return $classes;
}

Published by Santosh Shah

My name is Santosh Shah and blogs at santosh-shah.com

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.