#20431 closed defect (bug) (duplicate)
add_feed() - Warning
Reported by: | pavelevap | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.4 |
Component: | Feeds | Keywords: | |
Focuses: | Cc: |
Description
I tried to use add_feed() function, but there is probably some problem (using latest trunk).
Warning: in_array() [function.in-array]: Wrong datatype for second argument in C:\WWW\Wordpress\wp-includes\rewrite.php on line 88
Error is related to rewrite.php (line 88) and in_array() function and it seems that $wp_rewrite->feeds is null everytime, because $feeds is defined later in WP_Rewrite() class?
Code example:
function my_test() { echo '<item>'; } add_feed( 'test', 'my_test' );
So, I had to use (works well):
add_action( 'do_feed_test', 'my_test' );
I am not sure, but it is probably bug...
Change History (8)
#4
@
12 years ago
Sergey was right, this code works well:
function my_test() { echo '<item>'; } function my_feed() { add_feed( 'test', 'my_test' ); } add_action( 'init', 'my_feed' );
Is it the right way to do it?
First I found Codex entry for add_feed() - http://codex.wordpress.org/Rewrite_API/add_feed - and there was no mention about init hook. We can probably improve Codex entry, but this ticket can be closed, sorry for bothering...
#5
@
12 years ago
Hmmm, strange Trac warning:
Warning: The change has been saved, but an error occurred while sending notifications: (111, 'Connection refused')
#6
@
12 years ago
- Keywords reporter-feedback removed
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
#8
@
12 years ago
Thank you, Sergey!
Actually, I found another notice on parent Codex page: http://codex.wordpress.org/Rewrite_API
"Note that these rules are usually called inside the init hook."
Since
$wp_rewrite
is set after plugins are loaded, the function that callsadd_feed()
needs to be hooked to theinit
action.