[Resolved] Custom Body Class

Home Forums Support Custom Body Class

  • This topic has 2 replies, 2 voices, and was last updated 5 months ago by Leo.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1149801
    Andy

    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?

    #1149804
    Andy

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

    #1149860
    Leo
    Staff
    Customer Support

    Glad you’ve figured out 🙂

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.