Leave a Reply

2 comments

  1. Use locate_template() if you want to use a file from your theme. include() or require() works too.

    Sample code, tested:

    add_filter( 'login_message', 'wpse_73619_include_login_message' );
    
    function wpse_73619_include_login_message()
    {
        print '<pre>';
        locate_template( 'style.css', TRUE );
        print '</pre>';
    }
    
  2. Your function just constructs the URL. You’d need to include the file to get at its contents. You may be able to do this with get_template_part. I am not sure about the hook context. However, your file would need to generate a PHP variable or it will echo immediately rather than return.

    If you are using a text file, you could look into one of PHP’s file functions, like get_file_contents for more complicated manipulation of the file contents before your echo/return it. Or use output buffering.