I’m using the following if statement to add a class to the list item:
<?php
global $post;
$the_post_parent = $post->post_parent;
$the_post_ID = $post->ID;
$bbp_forums = get_posts('post_type=forum&orderby=title&order=asc&posts_per_page=-1&order=ASC');
?>
<li <?php if ( $post->ID == $the_post_ID || $post->ID == $the_post_parent ) echo 'class="current"'; ?>>
In this case, if the global post id matches the current post id the class .current is echoed.
I want to add three more conditions to the statement:
Excute the echo only if the current post type is a forum or topic or topic tag:
'forum' == get_post_type()
'topic' == get_post_type()
'topic-tag' == get_post_type()
So at this end if should read:
If the …
current post type is a forum OR topic OR topic tag AND its
global post id is equal to the current post id
OR the global post id
is equal to the current post parent
echo the class.
How that if-statement would look like?
You can do something like that :
if ( in_array(get_post_type(), array('forum', 'topic', 'topic-tag') && in_array($post->ID, array($the_post_ID,$the_post_parent) )