I'm trying to create a single template for the custom post type posts called 'press release' from a plugin.

This is the code I added to my plugin:

    function single_press_release_template($single_template) {
         global $post;
         $plugin_path = plugin_dir_path( __FILE__ );
         if ($post->post_type == 'press_release') {
         	if(file_exists($plugin_path . 'views/single-press_release.php')) {
         		$single_template = $plugin_path . 'views/single-press_release.php';
         		echo 'EXISTS! ' . $plugin_path . 'views/single-press_release.php';
         	}
         }
         return $single_template;
    }
    add_filter( 'single_template', 'single_press_release_template');

The file `single-press_release.php` (located in the 'views' plugins directory) contains this code:

    /**
     * Single Press Release
     *
     * @package WordPress
     */
    
    <?php
    
    echo 'Hello World';
    
    ?>

The result I get is a page without any main content (there is no 'hello world' text at all) but I can see the echo `'EXISTS! ' . $plugin_path . 'views/single-press_release.php'`:

[![blank main content][1]][1]

What am I doing wrong?


  [1]: https://i.sstatic.net/kdKSm.png