Hi support, I would like some of the items in my sidebar widget to show/hide depending on tags of the post the reader is viewing. I already have code that does this for items in the post by this code:
add_filter ('the_content', 'add_AdToPost', 11 );
function add_AdToPost ( $content ) {
if(!has_tag('Småspararguiden granskar finansbranschen')) {
$Ad = do_shortcode('<p><a id="article_footer_finansterapi" href="http://www.smaspararguiden.se/oberoende-radgivning/"><img src="https://www.smaspararguiden.se/wp-content/uploads/2023/05/banner-finansterapi.png" alt="Oberoende rådgiving med Småspararguiden"></a></p>');
} else {
$Ad = do_shortcode('<p><a id="article_footer_donation" href="https://smaspararguiden.typeform.com/to/fPRexP"><img src="https://www.smaspararguiden.se/wp-content/uploads/2022/10/banner-crowdfunding.jpg" alt="Gillar du att vi granskar branschen? Stötta oss!"></a></p>');
}
return is_singular('post') ? $content.$Ad : $content;
}
How do I go about to edit widget items with the same logic?