• I have a dynamic page, and I’m trying to update the page title to match the content. I’m trying to use pre_get_document_title, but I can’t seem to get the filter to work.

    I’ve removed <title> from header.php, and I have test code in functions.php:

    add_filter("after_setup_theme", function(){ add_theme_support("title-tag"); });
    
    add_filter("pre_get_document_title", function($title){
        error_log('test');
        return "test";
    });

    The error log works, but the title remains <page name> – <site name>.

    Any advice? Thanks!

  • The topic ‘Getting pre_get_document_title to work’ is closed to new replies.