Adding description to archive header

Hi, I’m trying to add the category/tag description to the archive pages (which use index.php).

I know I can use the following in the page-header.php template:

<?php echo category_description( get_category_by_slug('[category-slug]')->term_id ); ?>

But that doesn’t seem like a very Sage way of doing it (no pun intended). I get the impression there is a Sage object I can reference that already has this data, without performing 3 lookups (including the slug name itself).

Am I wrong? Is there a more direct way?

Thanks.

Here’s what I’ve got so far, if you know of a Sage object I can use instead, I’d be pleased to know. :smile:

<?php
if (is_archive()) {
?>
<span> <?php echo category_description(get_the_category()[0]->term_id); ?> </span>
<?php
  }
?>

There is nothing like that built into sage.
The way you did it is just fine.

2 Likes