$f=2\cdot \mathbb{1}_{(0,1)}+\mathbb{1}_{(-\infty, 0]\cup [1,\infty)}$
has all points that are local minimal.
If $f$ is continuos, then it is clear the only function is a constant:
We fix $f(a)\in \mathbb{R}$ and we define the set $A:=\{x\in \mathbb{R} : f(a)\leq f(x)\}$
Clearly $A$ is not empty, $a\in A$. Moreover it is closed because $[f(a),\infty)$ is closed in $\mathbb{R}$ and $f$ is continuous, so $f^{-1}([f(a),\infty))=A$ is closed.
By your assumption, if $x_0\in A$, $x_0$ is a local minimal of $f$, I.e. $f(a)=f_(x_0)\leq f(x)$ for each $x\in U$, where $U$ is some neighbourhood of $x_0$. This means $U\subseteq A$ and so $A$ is a closed and open in the connected set $\mathbb{R}$. This permit us to say
$\mathbb{R}=A=\{x\in \mathbb{R} : f(a)\leq f(x)\}$ for each choice of $a$.
But then if you consider a generic $x_0\in \mathbb{R}$, you get
$f(a)\leq f(x_0)$
Conversely
$a\in \mathbb{R}=\{x\in \mathbb{R} : f(x_0)\leq f(x)\}$
and so
$f(x_0)\leq f(a)$
Thus $f$ is a constant function.