One can find that $$f(x) = \frac{\pi}{2} + \sum_{n=1}^{\infty}\frac{2(-1+(-1)^n)}{\pi n^2}\cos(nx)$$
Now look at the case for $x=0$. We can find that $\sum_{n \text{ odd}, n \geq 1}^{\infty}\frac{1}{n^2}=\frac{\pi^2}{8}$. However, I am having a hard time proving the original equality since all the even terms would vanish. Thus it seems like the total sum should be equivalent to the sum of odd terms, but I know this is not the case. What nuance am I missing?
\begin{align} & \text{sum of even terms} = \sum_{n=1}^\infty \frac 1 {(2n)^2} \\[8pt] = {} & \frac 1 4 \sum_{n=1}^\infty \frac 1 {n^2} = \left( \frac 1 4 \times\big(\text{sum of all terms} \big)\right). \end{align} If the sum of the even terms is $1/4$ times the sum of all of the terms, then the sum of the odd terms is $3/4$ times the sum of all of the terms.
So multiply the sum of the odd terms by $4/3$ to get the sum of all of the terms.