Q:

Wordpress add_filter 'template_include' not working

My code is:
<?php

/**
 * Plugin Name: xxxxxxxxxxxx
 * Plugin URI: https://xxxxxxxxxxxxx.com
 * Description: xxxxxxxxxx
 * Version: 2020/05/01
 * Author: xxxxxxxxxxxxxxx
 * Author URI: https://xxxxxxxxxxxxx.com
 */

error_reporting(E_ERROR | E_PARSE);

function ss_replace_text($page)
{
    return $page;
}

add_filter('template_include', 'ss_replace');

function ss_replace()
{
    ob_start();
    ob_start('ss_replace_text');
}

It returns nothing, it should return the page content to the browser.

A:

You should have a look at how output buffers work in PHP ob-start reference
Then, you also need to understand how filters work. They basically take an argument ( which is the output ) send it to the filter and the filter needs to return ( not echo ) the modified output This is a good reference
Then, make sure that 'template_include' is the actual filter you want to use. That is usually used for loading a different file based on some conditions. I never used it for changing the output of the loaded file. template_include filter reference
The code should look something like this:
add_filter('template_include', 'ss_replace');

function ss_replace( $template )
{
    ob_start('ss_replace_text');

    echo $template;

    return ob_get_clean();
}

