WordPress add_rewrite_rule second argument not working

on the rewrite flush, the rewrite rule created by the custom post type overwrite yours because the target is the same.

to avoid this, you can use this filter

const TAXONOMY_PUBLICACOES = "publicacoes";

add_filter(TAXONOMY_PUBLICACOES . "_rewrite_rules", function ($rules) {

    unset($rules["publicacoes/(.+?)/page/?([0-9]{1,})/?$"]);

    return $rules;

});