Show post category title and description

hello!
for SEO it’s important to set title and description für the sites. in the theme listinghive in standard the title and category description is hide at the post category page. how can I add this?
Actually I tried to change the “post-archive.php” and set in child theme but then the title was set before every post and also the description was set after eacht post. Thanks!

Here is the site:
https://kinderklar.de/category/kunst-und-kultur/

Hi,

Please clarify, do you mean the title in the browser or would you like to add x1 text to the layout of the post category page?

I want to add h1 to the post category page and also unter the posts of these category also the description of the category page.

It’s possible, but requires code changes in the blog template file. If you use ListingHive, please create a child theme for it How to create a child theme - HivePress Help Center and copy index.php file from the parent theme. Then add this code after line 1 in the copied file:

<?php if ( is_category() ) : ?>
<h1><?php single_cat_title(); ?></h1>
<?php echo category_description(); ?>
<?php endif; ?>

Category pages should display titles and descriptions. We’ll make the same change in the next theme update, so no further actions are needed.

Hope this helps

Just sharing a more advanced snippet if you also want to show the content of the Blog page before the posts, in addition to showing category titles and descriptions (for RentalHive theme, it should be added right after line get_header(); in the index.php file):

if ( is_home() ) :
	echo apply_filters( 'the_content', get_the_content( null, false, get_option( 'page_for_posts' ) ) );
elseif ( is_category() ) :
	?>
	<h1 class="content-title"><?php single_cat_title(); ?></h1>
	<?php echo apply_filters( 'the_content', category_description() ); ?>
<?php endif; ?>
2 Likes

Thank you, @ihor

FYI - I added the category title with your code in the index.php. and I want to place the description under the posts of the category-page, therefor I used code snippet:

function add_category_description_after_posts( $query ) {
    if ( is_category() && is_main_query() ) {
        $category_description = category_description();
        if ( !empty( $category_description ) ) {
            echo '<div class="category-description">' . $category_description . '</div>';
        }
    }
}
add_action( 'loop_end', 'add_category_description_after_posts' );
1 Like