The $f(R,T)$ gravity is a theory whose gravitational action depends arbitrarily on the Ricci scalar, $R$, and the trace of the stress-energy tensor, $T$; its field equations also depend on matter Lagrangian, $mathcal{L}_{m}$. In the modified theories of gravity where field equations depend on Lagrangian, there is no uniqueness on the Lagrangian definition and the dynamics of the gravitational and matter fields can be different depending on the choice performed. In this work, we have eliminated the $mathcal{L}_{m}$ dependence from $f(R,T)$ gravity field equations by generalizing the approach of Moraes [Eur. Phys. J. C 79(8), 674 (2019)]. We also propose a general approach where we argue that the trace of the energy-momentum tensor must be considered an unknown variable of the field equations. The trace can only depend on fundamental constants and few inputs from the standard model. Our proposal resolves two limitations: first the energy-momentum tensor of the $f(R,T)$ gravity is not the perfect fluid one; second, the Lagrangian is not well-defined. As a test of our approach we applied it to the study of the matter era in cosmology, and the theory can successfully describe a transition between a decelerated Universe to an accelerated one without the need for dark energy.