Anybody can help me with this block of code? I' m still learning php, and this is for wordpress.
How do i add another post id "1221" into this block of code for the same function as post 425?
$additional_classes[] = ( is_object( $main_topic ) && 425 != $post->ID && !is_singular( $Theme->News->post_type ) ) ? 'term-' . $main_topic->slug : '';
Thanks in advance!!
Might be better to start without if-shorthand syntax to really understand whats happening in this line:
if(
is_object( $main_topic ) //checks, if $main_topic is an object
&& (1221 != $post->ID || 425 != $post->ID ) //checks, if $post->ID is NOT 1221 NOR 425
&& !is_singular( $Theme->News->post_type ) //checks, if post_type is NOT singular
) {
$additional_classes[] = 'term-' . $main_topic->slug;
} else {
$additional_classes[] = '';
}
If all three if-statements/conditions (&&
operator) are fulfilled, $additional_classes[]
will be set, otherwise its an empty string.
$additional_classes[] = ( is_object( $main_topic ) && 1221 != $post->ID && !is_singular( $Theme->News->post_type ) ) ? 'term-' . $main_topic->slug : '';
hope that solves it.