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

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).

Jay is founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or drawing on tablet devices. He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.

You can leave a comment on my original post.