I have created a widget which displays posts based on Display Posts shortcode. All works fine till I have added filter to public function widget()
to output titles only (and need to be executed only for that widget):
function display_posts_shortcode_clean_output( $output, $atts, $image, $title, $date, $excerpt, $inner_wrapper ) {
$output = $title;
return $output;
}
add_filter( 'display_posts_shortcode_output', 'display_posts_shortcode_clean_output', 10, 9 );
When I will use that widget on the page once all is OK. When twice, with different widget control option widget code is breaking on function display_posts_shortcode_clean_output
.
Do I need to move
add_filter( 'display_posts_shortcode_output', 'display_posts_shortcode_clean_output', 10, 9 );
to function __construct()
and then from public function widget()
call apply_filters
? But in that case where should display_posts_shortcode_clean_output()
function go?
Any clue?
Aucun commentaire:
Enregistrer un commentaire