I'm not sure if this helps but if you are set in using pure functions (ie Function[vars,body]) then perhaps this would help:
p=Function[{x,z},f[x,z]]
and D[p[x,z],x], D[p[x,z],z] should return the appropriate derivatives of the body (ie the formula) of your function (the f[x,z] part)
Also, defining x=Function[theta,g[theta]] and calling D[p[x[theta],z],theta] and D[p[x[theta],z],x[theta]] should work as expected.
I don't know what you want to achieve but (in my experience) perhaps you'd be better off by defining your functions using setdelayed (:=) as in f[x_]:=Module[{local vars}, body[x]] when using D[]