How to remove the Title and Description from Archive Pages in GeneratePress

- by

I’ve been having great fun with the Page Hero feature in GeneratePress, and I wanted to use it for archive pages too. By default however, the Archive Title and Description show up in the Page Hero as well as underneath it. This doesn’t happen on single posts, so we’ll have a bit of work to do to make them not show up twice.

Rather than hack the actual archive template page, I found two hooks that can accomplish this nicely: generate_archive_title and generate_archive_description. Knowing of their existence means we can simply remove each action and neither title nor description will be printed:

add_action( 'wp', function() {
  if ( is_category() || is_tag()) {
      remove_action( 'generate_archive_title', 'generate_archive_title' );
      remove_action( 'generate_archive_description', 'generate_archive_description' );
  };
}, 20 );

In this example I’m removing both Tag and Category archives. Amend the conditional as needed. There’s a good example in the GeneratePress Docs about making the description show up only on the first archive page (neat).

Add your voice!

This site uses Akismet to reduce spam. Learn how your comment data is processed.