Theorem: Let $(X_n)$ be a sequence of random variables. Then $X_n \to X$ in probability, iff for every subsequence $(n_k)$ there exists sub-subsequence $(n_{k_m})$ such that $X_{n_{k_m}} \to X$ almost surely.
Firstly lemma: If $X_n \to X$ in probability, then there exists subsequence $(n_k)$ such that $X_{n_k} \to X$ almost surely.
Proof of lemma: By convergence in probability, we have a subsequence $(n_k)$ such that $\mathbb P(|X_{n_k} - X| \ge \frac{1}{k^2}) \le \frac{1}{k^2}$. Hence $\sum_{k=1}^\infty \mathbb P(|X_{n_k} - X| \ge \frac{1}{k^2}) < \infty$ so by borel cantelli, almost surely we have $|X_{n_k} - X| < \frac{1}{k^2}$ starting from some $k>K$, so $X_{n_k} \to X$ almost surely.
Proof of theorem.
By Lemma we have => direction (since for any subsequence $(n_k)$ we have $X_{n_k} \to X$ in probability, too).
"<=" Assume contrary, that there $X_n \not \to X$ in probability. Hence by definition, there exists $\varepsilon >0, \delta >0$ and subsequence $(n_k)$ such that $\mathbb P(|X_{n_k} - X| > \varepsilon) > \delta$ for every $k \in \mathbb N$. But from that subsequence $(n_k)$ we cannot choose any sub-subsequence $(n_{k_m})$ such that $X_{n_{k_m}} \to X$ almost surely (because $X_{n_{k_m}} \not \to X$ in probability and this is necessary condition).
Having theorem we can proceed as follows in your question:
Let $f$ be continuous and $X_n \to X$ in probability. We want to show that $Y_n := f(X_n) \to f(X) =: Y$ in probability. Take any subsequence $(n_k)$. We know that there exists sub-subsequence $(n_{k_m})$ such that $X_{n_{k_m}} \to X$ almost surely. Hence $Y_{n_{k_m}} \to Y$ almost surely (cause continuous functions of pointwise convergent sequences are pointwise convergent). Since $(n_k)$ was arbitrary, by theorem we know that $Y_n \to Y$ in probability.