Try_files Rewrite Request exclude path help plz

I think you were on the right path with your first attempt using the expanded form of try_files. the matcher looks a bit malformed however, please see Request matchers (Caddyfile) — Caddy Documentation.

Try this instead

@try_files {
    not path /wp-admin/*
    file {
        try_files {path} {path}/ /index.php
    }
}
rewrite @try_files {http.matchers.file.relative}

edit: removing ?{query} from code snippet as it is implied, thanks @francislavoie