display a widget on specific category and its sub categories

you can test category identifier and parent in a widget with that :

class WidgetExample extends \WP_Widget
{

    public const IDENTIFIANT = "example1";
    public const CATEGORY_ID = 25;

    public function __construct()
    {
        parent::__construct(
              self::IDENTIFIANT
            , "Example"
        );
    }

    public function widget($args, $instance)
    {

        if (!is_category()) {
            return;
        }

        $currentCategory = get_queried_object();

        if (    (self::CATEGORY_ID !== $currentCategory->ID)
            &&  (self::CATEGORY_ID !== $currentCategory->parent)
        ) {
            return;
        }


        echo "We are on category " . self::CATEGORY_ID;


    }

    public function form($instance) {
    }

}

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş