  Motivated by the analogy between the spacetime and the solid with
inhomogeneous elasticity modulus, we present an alternative method to obtain
the field equation of any diffeomorphism-invariant gravity, by extremizing the
constructed entropy function of the displacement vector field of spacetime
solid. In general stationary spacetimes, we show that the Wald entropy of
horizon arises from the on-shell entropy function of spacetime solid.
