robahas (@robahas)

Forum Replies Created

Viewing 1 replies (of 1 total)

  • robahas
    Participant

    @robahas

    Hi – I figured this out. Everything under a forum category is a descendant. So based on that you can select an entire “section” of the forum. Here is the code (this is in the genesis framework, so adjustments would be needed for applying to the body class in non-genesis installations). The key is to get the ancestors of the current post, and if your top level forum is included, then apply the css.

    add_filter( 'body_class', 'sp_body_class' );
    function sp_body_class( $classes ) {
        global $post;
        $anc = get_ancestors($post->ID, 'post');
         if ( is_single( '1530' ) || in_array('1530', $anc) )
              $classes[] = 'custom-class';
              return $classes;
    }
Viewing 1 replies (of 1 total)