Skip to:
Content
Pages
Categories
Search
Top
Bottom

Apply a style to a particular category (section) of the forum


  • robahas
    Participant

    @robahas

    Hi – Is there a way to style a particular category and all its associated forums, topics and replies? I can see how to apply a style to a single forum/category, but that does not propagate to the rest.

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)

  • Robin W
    Moderator

    @robin-w

    not sure I can help, but tell me how you would ‘apply a style to a single forum/category’ and I’ll see if I can think of how to take that wider


    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 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar