add_filter('wp_title') doesn't replace my title tag (WordPress plugin)
<p>I am trying to change the title of my detail page to the name of the car.
I have made a plugin that fills the detail page with the car information. But now I can't get the add_filter('wp_title') to work in my plugin.</p>

<p>Here is the code I tried:</p>

<pre><code>function init() {
    hooks();
}
add_action('wp', 'init');

function hooks() {
    if(get_query_var('car_id') != "") {
        add_filter('wp_title', 'addTitle', 100);
        add_action('wp_head', 'fillHead');
    }
    add_shortcode('showCar', 'showCar');
}

function addTitle() {
    $api_url_klant = API_URL . '/gettitle/' . get_option("ac") . '/' . get_query_var('car_id');
    $title = getJSON($api_url_klant);
    return $title['merk'] . " " . $title['model'] . " - " . $title['bedrijf'];
}
</code></pre>

<p>The addTitle() function works just fine. It returns the right name. Also the add_action('wp_head') works as well. I only can't get the wp_title filter not to work.</p>

<p>Am I executing this filter at the wrong moment or what am I doing wrong?</p>