We study that over some types of trees with a given number of vertices, which trees minimize or maximize the total number of subtrees. Trees minimizing (resp. maximizing) the total number of subtrees usually maximize (resp. minimize) the Wiener index, and vice versa. Here are some of our results: (1) Let Tnk be the set of all n-vertex trees with k leaves, we determine the maximum (resp. minimum) value of the total number of subtrees of trees among Tnk and characterize the extremal graphs. (2) Let Pnp,q be the set of all n-vertex trees, each of which has a (p,q)-bipartition, we determine the maximum (resp. minimum) value of the total number of subtrees of trees among Pnp,q and characterize the extremal graphs. (3) Let Anq be the set of all q-ary trees with n non-leaf vertices, we determine the minimum value of the total number of subtrees of trees among Anq and identify the extremal graph.