Categories – Show some text in posts belonging to specific category

I am trying to add some text at the end of each post related to a specific category. I am using following code –

<div class="repair-tool">
    <?php 
    $catarray = get_the_category( $post->ID );
    foreach ($catarray as $cat) {
        $catid = $cat->term_id;
    
        if ($catid == 1234) {
          echo 'text';
        }
    
    } ?>
</div>

It is working successfully but the div class I am using is showing in each and every post of the website.

Leave a Comment