So I'm trying this code:
<?php global $post; $my_query = new WP_Query('showposts=8&category_name=featured'); while ($my_query->have_posts()): $my_query->the_post(); $do_not_duplicate = $post->ID; $category = get_the_category(); $content = get_the_content(); $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID) , 'main-thumbs'); $tn_id = get_post_thumbnail_id($post->ID); $img = wp_get_attachment_image_src($tn_id, 'main-thumbs'); $width = $img; $height = $img; ?> .... <div class="cat-square <?php echo esc_html($category->slug) ?>">
with this, I can style a generic div (cat-square) and then add some additional styling depending on the category the post is in. So far so good, this work as a charm. Exception made that categories, which are all scientific disciplines, can also belong to
Featured category . So, sometimes the category (let's say Physics) is replaced by Featured category.
How can prevent this from happening? Please note that I don't mean to exclude the post itself, only the
Featured category nicename and slug