im trying to alter content on posts by way of a widget.
the widget has a section in a sidebar that displays categories. and a section on each post.
all works except add_filter is not fired, when placed INSIDE the class. why inside the class? i need a boolean on whether to fire or not. that flag is a widget control option, selected by the user. (outside of course, it is just fired as expected)
class XXX extends WP_Plugin {
function widget( $args, $instance ) {
if ($instance['displayonpost'])
add_filter( 'the_category', 'filter_the_category');
//display categories on widget side
}
}
//outside of class, but should be fine
function filter_the_category() {
...
}
one possibility. seems like the above WP_Widget::widget function is called late in the WP sequence.
i have tried placing that add_filter call in the WP_Widget::WP_Widget constructor but the instance properties are not set.