Getting and displaying the categories within your posts loop can be done for example like this,
$categories = get_the_category();
if ( $categories ) {
$cat_links="";
foreach ( $categories as $category ) {
$cat_links .= sprintf(
'<a href="https://wordpress.stackexchange.com/questions/346001/%s">%s</a>',
esc_url( get_category_link( $category->term_id ) ),
esc_html( $category->name )
);
}
printf(
'<div class="categories"><span class="title">%s</span>%s</div>',
esc_html__( 'Categories:', 'text-domain' ),
$cat_links
);
}
The exact “how” kind of depends on the theme you’re using.
If the theme provides an action hook at the end of the loop item, then you could use that. Like so,
function my_categories_callback() {
// the category code here
}
add_action( 'some_action_hook_at_the_end_of_loop_item', 'my_categories_callback' );
If your theme uses a template part for the loop item, then copy it to your child theme and add the category code for example like this to the partial file,
<!-- some loop item html -->
<?php // the category code here ?>
<!-- loop item closing html tag -->
Or if your theme only has home.php/archive.php/index.php/etc. file for displaying the loop, then copy it to your child theme and add the code above directly to that files Loop. Something along these lines,
<?php while (have_posts()) : the_post(); ?>
<?php // Individual Post Styling ?>
<?php // the category code here ?>
<?php endwhile; ?>