## categories – Inline If statement to echo CSS

Question

I have a line of code in my template I would like to add the css class “has-video” to if the post is within a certain category.

I am trying to do this inline with ' . ( if (in_category(42)) echo 'has-video') ? ' but I get a syntax error, unexpected ‘if’ (T_IF)

I’m not great with my PHP and know this is close but not great :/

Here is the whole echo code:

echo '<section id="cooked-recipe-list-' . $list_id_counter . '" class="cooked-clearfix cooked-recipe-' .$list_style . ' cooked-recipe-loader' . ( in_array( $list_style,$masonry_layouts ) ? ' cooked-masonry' : '' ) . ( isset($atts['columns']) &&$atts['columns'] ? ' cooked-columns-' . \$atts['columns'] : '' ) . ' ' . ( if (in_category(42)) echo 'has-video') ? '">';


0
2 years 2021-03-21T20:52:01-05:00 0 Answers 0 views 0