Site logo

Archived topic

Custom Body Class

2 replies · Started by Andy on January 30, 2020

Viewing posts 1–3 of 3

Hi all,

I'm trying to add a cusotm body class to a Custom Post Type Archive using the filter below in my child themes functions file, but it's not working:

//* Add custom body class to CPT Archive
add_filter( 'body_class', 'custom_body_class' );
function custom_body_class( $classes ) {
	
	if ( is_post_type_archive( 'courses' )  )
		$classes[] = 'all-courses';
		return $classes;
}

Any idea where I'm going wrong?

Nevermind, I just realised the archive is plugin generated not theme generated! Doh!

Glad you've figured out :)

This archived topic is closed to new replies.