How to set up a If is_singular statement?

I’ve got this code here, and I want it to exclude this div from being parsed if the condition is false.

<?php if ( ! is_single() ) { ?>
<div class=”cat-container”>
<a class=”post-cat bg-darkpurple” href=”<?php echo $category_link ?>”><?php echo $category_name ?></a>
<?php } ?>

However, It does not work as intended. It’s either true or false for all results depending on if ! is included or not. I feel like I’m missing something really simple.

Basically, I don’t want the div to be sent to the loop If it is a page, not a post(Since pages don’t have categories.)

I’ve tried is_single, Is_singluar, and (‘post’) in there as well, to no avail.

Thanks for any insight

Read more here:: How to set up a If is_singular statement?

Leave a Reply

Your email address will not be published. Required fields are marked *