[proofplan]
The inclusion $\operatorname{Ord}^M \subset \operatorname{Ord}^{M[G]}$ follows from $M \subset M[G]$ and transitivity. For the reverse inclusion, take an ordinal $\alpha \in M[G]$ and write it as the interpretation $\tau_G$ of a $\mathbb{P}$-name $\tau \in M$. We prove by induction on the name-rank of names that whenever a name evaluates to an ordinal, its value is bounded by its name-rank. Applying this bound to $\tau$ places $\alpha$ inside an ordinal of $M$, and transitivity of $M$ then forces $\alpha \in M$.
[/proofplan]
[step:Fix the valuation and name-rank conventions]
For every $\mathbb{P}$-name $\sigma$, define its valuation by $G$ recursively as
\begin{align*}
\sigma_G = \{\rho_G : \exists p \in G \text{ such that } (\rho,p) \in \sigma\}.
\end{align*}
Since $G$ is $M$-generic, $M[G]$ is by definition the forcing extension generated by interpreting all $\mathbb{P}$-names from $M$, so every element of $M[G]$ is of the form $\sigma_G$ for some $\mathbb{P}$-name $\sigma \in M$. This is the only point at which genericity is used directly in the ordinal-preservation argument; the rest of the proof uses the valuation recursion for names.
Let $V^{\mathbb{P}}$ denote the class of all $\mathbb{P}$-names. Define the name-rank function $\operatorname{nrk}: V^{\mathbb{P}} \to \operatorname{Ord}$ by
\begin{align*}
\operatorname{nrk}(\sigma)=\sup\{\operatorname{nrk}(\rho)+1 : \exists p \in \mathbb{P} \text{ such that } (\rho,p) \in \sigma\}
\end{align*}
for every $\sigma \in V^{\mathbb{P}}$.
Thus, whenever $(\rho,p) \in \sigma$, we have
\begin{align*}
\operatorname{nrk}(\rho) < \operatorname{nrk}(\sigma).
\end{align*}
Because $\tau \in M$ and $M$ is a transitive model of $\mathrm{ZFC}$, the recursive construction of $\operatorname{nrk}(\tau)$ is carried out inside $M$, and $\operatorname{nrk}(\tau) \in \operatorname{Ord}^M$.
[/step]
[step:Show that names evaluating to ordinals are bounded by their name-rank]
We prove by transfinite induction on $\delta \in \operatorname{Ord}$ the following assertion:
For every $\mathbb{P}$-name $\sigma$ with $\operatorname{nrk}(\sigma)=\delta$, if $\sigma_G$ is an ordinal, then
\begin{align*}
\sigma_G \subset \delta.
\end{align*}
Fix $\delta \in \operatorname{Ord}$ and assume the assertion holds for every name-rank $<\delta$. Let $\sigma$ be a $\mathbb{P}$-name with $\operatorname{nrk}(\sigma)=\delta$, and suppose that $\sigma_G$ is an ordinal. Let $\beta \in \sigma_G$. By the definition of valuation, there exist a $\mathbb{P}$-name $\rho$ and a condition $p \in G$ such that $(\rho,p) \in \sigma$ and
\begin{align*}
\beta = \rho_G.
\end{align*}
Since $(\rho,p) \in \sigma$, the definition of name-rank gives
\begin{align*}
\operatorname{nrk}(\rho) < \operatorname{nrk}(\sigma)=\delta.
\end{align*}
Because $\sigma_G$ is an ordinal and $\beta \in \sigma_G$, the element $\beta$ is itself an ordinal. Hence $\rho_G=\beta$ is an ordinal, so the induction hypothesis applied to $\rho$ yields
\begin{align*}
\rho_G \subset \operatorname{nrk}(\rho).
\end{align*}
Since $\rho_G$ is an ordinal and $\rho_G \subset \operatorname{nrk}(\rho)$, it follows that
\begin{align*}
\rho_G \in \operatorname{nrk}(\rho)+1.
\end{align*}
Also $\operatorname{nrk}(\rho)+1 \leq \delta$, because $\operatorname{nrk}(\rho)<\delta$. Therefore $\rho_G \in \delta$, and hence $\beta \in \delta$. Since $\beta \in \sigma_G$ was arbitrary, $\sigma_G \subset \delta$.
[guided]
The point of the induction is to control the possible ordinal value of a name by looking only at how deeply names are nested inside it. Here $V^{\mathbb{P}}$ denotes the class of all $\mathbb{P}$-names, and $\operatorname{nrk}:V^{\mathbb{P}}\to\operatorname{Ord}$ is the name-rank function defined above. We prove the following precise statement by induction on the ordinal $\delta$: if a name $\sigma$ has name-rank $\delta$ and its interpretation $\sigma_G$ is an ordinal, then every element of $\sigma_G$ belongs to $\delta$.
Fix $\delta \in \operatorname{Ord}$ and assume the statement has already been proved for every smaller name-rank. Let $\sigma$ be a $\mathbb{P}$-name satisfying $\operatorname{nrk}(\sigma)=\delta$, and assume that $\sigma_G$ is an ordinal. To prove $\sigma_G \subset \delta$, take an arbitrary element $\beta \in \sigma_G$. By the recursive definition of valuation, membership in $\sigma_G$ means that $\beta$ comes from some first coordinate of a pair in $\sigma$: there are a $\mathbb{P}$-name $\rho$ and a condition $p \in G$ such that $(\rho,p) \in \sigma$ and
\begin{align*}
\beta = \rho_G.
\end{align*}
Now the rank decreases when we pass from $\sigma$ to such a first-coordinate name $\rho$. Indeed, the definition
\begin{align*}
\operatorname{nrk}(\sigma)=\sup\{\operatorname{nrk}(\eta)+1 : \exists q \in \mathbb{P} \text{ such that } (\eta,q)\in\sigma\}
\end{align*}
implies, for our particular pair $(\rho,p)\in\sigma$, that
\begin{align*}
\operatorname{nrk}(\rho)<\operatorname{nrk}(\sigma)=\delta.
\end{align*}
We may therefore apply the induction hypothesis to $\rho$, but only after checking its hypothesis. The value $\rho_G$ is equal to $\beta$, and $\beta$ is an element of the ordinal $\sigma_G$. Every element of an ordinal is an ordinal, so $\rho_G$ is an ordinal. The induction hypothesis gives
\begin{align*}
\rho_G \subset \operatorname{nrk}(\rho).
\end{align*}
Since $\rho_G$ is itself an ordinal, the inclusion $\rho_G \subset \operatorname{nrk}(\rho)$ says exactly that $\rho_G \leq \operatorname{nrk}(\rho)$, equivalently
\begin{align*}
\rho_G \in \operatorname{nrk}(\rho)+1.
\end{align*}
Because $\operatorname{nrk}(\rho)<\delta$, we have $\operatorname{nrk}(\rho)+1\leq\delta$, and hence
\begin{align*}
\rho_G \in \delta.
\end{align*}
Using $\beta=\rho_G$, this proves $\beta\in\delta$. Since $\beta$ was arbitrary, $\sigma_G\subset\delta$.
[/guided]
[/step]
[step:Apply the rank bound to the given ordinal]
Let $\alpha \in \operatorname{Ord}^{M[G]}$. Since $\alpha \in M[G]$, choose a $\mathbb{P}$-name $\tau \in M$ such that
\begin{align*}
\tau_G=\alpha.
\end{align*}
Applying the previous step to $\sigma=\tau$ and $\delta=\operatorname{nrk}(\tau)$ gives
\begin{align*}
\alpha=\tau_G \subset \operatorname{nrk}(\tau).
\end{align*}
Since $\alpha$ is an ordinal, this implies
\begin{align*}
\alpha \in \operatorname{nrk}(\tau)+1.
\end{align*}
The ordinal $\operatorname{nrk}(\tau)+1$ belongs to $M$, because $\operatorname{nrk}(\tau)\in\operatorname{Ord}^M$ and $M$ satisfies the successor operation on ordinals. Since $M$ is transitive and $\alpha \in \operatorname{nrk}(\tau)+1 \in M$, we conclude that $\alpha \in M$. Thus
\begin{align*}
\operatorname{Ord}^{M[G]} \subset \operatorname{Ord}^M.
\end{align*}
[/step]
[step:Combine both inclusions]
If $\alpha \in \operatorname{Ord}^M$, then $\alpha \in M \subset M[G]$. Since $M$ is transitive and forcing extensions of transitive models are transitive under the valuation recursion above, ordinalhood is absolute between $M$ and $M[G]$ for sets already in $M$: the same transitive set well-ordered by membership in $M$ remains a transitive set well-ordered by membership in $M[G]$. Hence the same set $\alpha$ is an ordinal in $M[G]$. Hence
\begin{align*}
\operatorname{Ord}^M \subset \operatorname{Ord}^{M[G]}.
\end{align*}
Together with the reverse inclusion proved above, this gives
\begin{align*}
\operatorname{Ord}^{M[G]}=\operatorname{Ord}^M.
\end{align*}
This completes the proof.
[/step]