#2930 closed defect (bug) (invalid)
Filter called for wp_title does not receive all arguments
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | Template | Keywords: | |
| Focuses: | Cc: |
Description
(Using WordPress Version 2.0.3)
The function called by the filter wp_title should receive both the title and the separator as arguments, according to template-functions-general.php line 201.
However, the only argument received by the callback function is the title, and no indication of the separator.
You can test this by installing the following code as a plugin:
<?php
/*
Plugin Name: Title Filter Test
Author: Sargant
Description: Demonstrates problem with wp_title filter
Version: 1
*/
add_filter('wp_title', 'title_filter_argument_test');
function title_filter_argument_test() {
var_dump(func_get_args());
}
?>
Expected output:
The function wp_title() should var_dump an array with two elements - the title and the separator.
Actual output:
The var_dump shows just one function argument - the title alone.
Attachments (1)
Change History (5)
#1
@
20 years ago
- Resolution set to invalid
- Status changed from new to closed
In this case, apply_filters() should return single value, not an array.
#2
@
20 years ago
In order to get additional values, you must specify so in your add_filter() call.
Like so:
add_filter('wp_title', 'title_filter_argument_test', 10, 2);
10 is the order of execution (10 is default) and 2 is the number of params you want passed (you want both, so you specify 2). Now your function will get both params.
Demonstration Plugin