I want to display a custom HTML snippet after a page or post title.

Any theme which follows the WP guidelines will output the post or page title using `the_title()`. For example, the [TwentyTwentyOne WP theme][1] does it as follows:

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
    	<header class="entry-header alignwide">
    		<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
    		<?php twenty_twenty_one_post_thumbnail(); ?>
    	</header>

    ...

So, my first attempt has been to use [the_title][2] filter.

    function filter_the_title( $title ) {
        return $title . '<h2>Whatever</h2>';
    }
    add_filter( 'the_title', 'My\Namespace\filter_the_title' );

But this does filter the title text itself, not the whole output, so my custom HTML will be inside the `<h1>` tag.

How may I add custom content after `the_title()` output, without touching the theme files (should work as a plugin for any standard WP theme.


  [1]: https://github.com/WordPress/twentytwentyone/blob/trunk/template-parts/content/content-single.php
  [2]: https://developer.wordpress.org/reference/hooks/the_title/