Basically, I would like to activate a CSS class only if the current page is a certain custom post type (e.g.
?bbp_forum=technology) or if the current page is a child of that custom post type.
The first custom post type is called '
bbp_forum.' Each '
bbp_forum' can have a '
bbp_topic' (which is another custom post type).
Like it is described in this picture:
I used to do the following in order to assign the class
current to the current '
<?php global $post; $the_post_ID = $post->ID; $cat_posts = get_posts('post_type=bbp_forum&posts_per_page=-1'); var_dump($the_post_ID); ?> <?php foreach ( $cat_posts as $post ) : ?> <li <?php if ( $post->ID == $the_post_ID ) echo 'class="current"'; ?>> <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a> </li> <?php endforeach; ?>
but it doesn't work for a child of the '