Add custom code at start and end of all posts in a category

You can edit the template associated with your Category template in your theme. If you don’t own the theme, you can make a Child theme of it to modify things.

For example, in my local WordPress dev environment, I have the theme TwentyTwenty active, and the template responsible for displaying is the index.php (typically it’s the category.php or so). And the index.php is loading the /template-parts/content.php for displaying each of the post.

Now it’s dead simple to add whatever you want to add and however. Suppose the code below is responsible for displaying the button you can see in the image:

<!-- </div> --> <!-- .section-inner -->

<?php if ( is_category() ) { ?>
    <div class="section-inner medium has-text-align-center">
        <button class="button" data-id=<?php the_ID(); ?>>Participate in Quiz</button>
    </div>
<?php } ?>

I passed a data-id attribute to each of the buttons, so that you can do whatever you want with each of the button individually.

button after each post in category listing - WordPress