WordPress after content Hook & external template part

Be aware that a mix of return and echo from a function will change text positioning.

If you take this simple example :

function test(){
    $the_test="test return";
    echo 'test echo';
    return $the_test;
}

echo test();

Whatever the place of the echoed line, this line will be always print before echo test(); because echo is called before the return $the_test;

You need to play with get_template_part and/or template_redirect action to display your content like you want.

Hope your understand what I mean and the relation with your issue 😉