Emotions on Wall Street tend to swing like a pendulum, going from far too excited to far too pessimistic. That happens on a large scale, but also on the individual stock level. Being a contrarian and buying when others are selling isn't easy.

But sometimes it can let you pick up great companies at attractive prices. Just such an opportunity likely exists today with PepsiCo (PEP -0.55%) and Hershey (HSY 0.08%), two dividend stocks you might want to double up on while you can.

A person writing the word dividends.

Image source: Getty Images.

PepsiCo is struggling, but it should survive just fine

Right now beverage giant Coca-Cola is outperforming PepsiCo, business wise and stock wise. That's not unusual, noting that at other times PepsiCo has outperformed Coca-Cola. That said, PepsiCo's underwhelming financial results appear to have investors running for the hills, with the stock down around 30% from its 2023 highs.

The key here is that PepsiCo has been through hard times before and continued to reward investors well for sticking around. It is, after all, a Dividend King with more than five decades of annual dividend increases behind it. Achieving this level of dividend success requires a strong business model that gets executed well in good times and bad.

Right now is just a bad time for PepsiCo. And that's OK, particularly if you think in decades and not days. It's the reason why the dividend yield is so attractive at 4.3%.

What's important to note, however, is that PepsiCo remains a diversified consumer staples giant. It continues to have an industry leading distribution system, marketing chops that rival those of Coca-Cola, and ample cash to support its R&D efforts. PepsiCo also has the wherewithal to be an industry consolidator, which helps to keep its product roster relevant with consumers. On that score, it recently bought Mexican-American food maker Siete and probiotic beverage company Poppi.

Given the history here, long-term dividend investors should probably give PepsiCo the benefit of the doubt and buy the stock while it looks cheap.

Hershey isn't hiding its troubles

Another consumer staples company worth looking at right now is Hershey, which is focused on the snack category of the food niche. Specifically, it makes confections (chocolate, for example) and salty snacks (pretzels and popcorn). The big problem today is on the cost side of the equation, noting that Hershey expects 2025 revenue to increase around 2% but that earnings are projected to drop in the mid 30% range.

Growth is being helped along by bolt-on acquisitions in both the confection space and in the salty snack area. Earnings are getting crushed by the shocking rise in the price of cocoa, a key ingredient in making chocolate.

Given that cocoa comes from trees, there's no quick fix here. However, high commodity prices, over time, will likely result in increased investment in cocoa production. That, in turn, should lead to lower cocoa prices. Hershey just has to muddle through controlling the things it can control while it waits.

That is, indeed, what management is doing. It has been upgrading its distribution system and making small acquisitions. Investors aren't giving management much leeway, with the stock having lost around a third of its value since 2023. The dividend yield is now up to 3.3%. Although Hershey hasn't increased its dividend every year like PepsiCo, the dividend has trended generally higher for decades.

If you can stand going against the crowd

PepsiCo and Hershey are clearly out of favor on Wall Street given their deep stock price declines. But they both remain well run businesses that are doing what needs to be done to survive and thrive over the long term. If you are an investor that thinks in decades, both are worth a deep dive right now. And if you own them already, you might consider doubling up on the investment. If history is any guide, they will both muddle through to better days. And when that happens the Wall Street pendulum will probably swing back in a positive direction again.