In this paper, we report that reversals of the large-scale circulation in two-dimensional Rayleigh–Bénard (RB) convection can be suppressed by imposing sinusoidally distributed heating to the bottom plate. We examine how the frequency of flow reversals depends on the dimensionless wavenumber
$k$
of the spatial temperature modulation with various modulation amplitude
$A$
. For sufficiently large
$k$
, the flow reversal frequency is close to that in the standard RB convection under uniform heating. However, when
$k$
decreases, the frequency of flow reversal gradually becomes lower and can even be largely reduced. Furthermore, we examine the growth of the corner roll and the global flow structure based on Fourier mode decomposition, and reveal that the size of the corner roll diminishes as the wavenumber decreases. The reason is that the regions occupied by the cold phase can absorb heat from the hot plumes and thus lower their temperature, which reduces the corner roll's kinetic energy input provided by the buoyancy force, and weakens the feeding process of the corner rolls. This results in the locking of the corner roll into a smaller region near the corner, making it harder for a reversal to occur. Using the concept of horizontal convection caused by non-uniform heating, we find a relevant parameter
$k/A$
to describe briefly how the reversal frequency depends on wavenumber and modulation amplitude. The present work provides a new way to control the flow reversals in RB convection through modifying temperature boundary conditions.