#8: get_the_generator_{$type}

The get_the_generator_{$type} filter allows you to modify the generator meta tag provided by WordPress in certain contexts.

It is evaluated in get_the_generator() in the wp-includes/general-template.php file.

get_the_generator_{$type} is a dynamic filter, meaning part of the filter tag changes based on the context. It accepts 2 arguments:

  1. string $gen The generator meta tag
  2. string $type The generator type

The dynamic portion of the filter tag, $type accepts html, xhtml (default), atom, rss2, rdf, comment, or export. When you add your filter, the tag takes the form of get_the_generator_html or get_the_generator_xhtml and so on.

Example:

Sometimes people will use a filter to disable the generator tag altogether, termed “security by obscurity”. The following example instead tries to have a little fun with the generator tag by replacing the WordPress version number with its corresponding jazz musician! We’ll filter on the default xhtml context.