PHOENIX — Michael Pineda’s troubles aren’t limited to just the first inning.

No, the inconsistent righthander showed Tuesday night he can be bad in any frame.

The third and fifth hurt him the most in a 5-3 loss to the Diamondbacks in front of 30,913 at Chase Field, the Yankees’ second straight defeat to start this seven-game trip west.

Pineda (1-5, 6.60 ERA) allowed five runs and nine hits in five innings, though the 27-year-old at times demonstrated the plus-stuff (nine strikeouts, one walk) that has long had the Yankees dreaming of a top-of-the-rotation pitcher.

“The more he’s ahead in the count, the worse the numbers turn and it’s hard to figure out,” pitching coach Larry Roths child said. “At the end of the day, one of the problems is the stretch position, the quality of pitches are not the same, and we need to fix that . . . We need to end this right now and get this straightened out.”

Nick Ahmed, the No. 8 hitter, hit an 0-and-2 slider for an RBI single in the second inning that tied the game at 1 and Paul Goldschmidt hit a 1-and-2 slider for an RBI single in the third that made it 2-1. Welington Castillo jumped on a first-pitch fastball in the same inning for another RBI single and, in the fifth, Jake Lamb pounded a 1-and-0 fastball out for a two-run shot that made it 5-1.

advertisement | advertise on newsday

“I know I’m better than that,” Pineda said. “I’m struggling but I need to keep working hard and be better. I have to not make so many mistakes. If you make mistakes at this level, they’ll get you.”

Joe Girardi and Rothschild seemed to have a blunt conversation in the dugout with Pineda during the game, though the manager didn’t disclose what was said. Pineda’s body language on the mound didn’t look good, but Pineda typically, in good times and bad, shows emotion.

“He knows he’s better than this,” Girardi said. “He’s always been animated. That’s who he is.”

Girardi could be describing himself, as well as his club, which fell to 16-22 and committed two errors, giving them four in the series.

“You can’t play like that and expect to win, I know that,” Girardi said. “It’s just poor baseball.”

Yankees videos

Zack Greinke, mostly a disappointment eight games into his Diamondbacks’ career, was terrific Tuesday night until stalling somewhat in the eighth and getting little help from his bullpen. The 32-year-old righthander, signed to a six-year, $206.5-million deal in the offseason after a 2015 in which he went 19-3 with a 1.66 ERA with the Dodgers, allowed three runs and five hits in seven-plus innings.

After Starlin Castro’s second-inning homer gave the Yankees a 1-0 lead, Greinke retired 12 straight.

By the time that streak was broken, a one-out single by pinch hitter Dustin Ackley in the sixth, the Diamondbacks (19-23) led 5-1.

Didi Gregorius led off the eighth with a single against Greinke and Aaron Hicks singled, putting runners at the corners. With righty-hitting pinch hitter Rob Refsnyder on deck, Arizona manager Chip Hale called on righthander Daniel Hudson. Girardi sent up switch hitter Carlos Beltran, who grounded out to make it 5-2. Jacoby Ellsbury’s single brought in Hicks to make it 5-3.

Brett Gardner got ahead of Hudson 3-and-0 before taking three straight called strikes. The 3-and-1 pitch looked a bit high and the next one appeared perhaps low, causing Gardner to stand and yell at plate umpire Fieldin Culbreth for several seconds before Girardi got between the two, the manager getting a few words in, as well, but staying in the game.

advertisement | advertise on newsday

Hudson struck out Mark Teixeira to end the inning.

Righty sidearmer Brad Ziegler walked Chase Headley with two outs in the ninth but retired Gregorius on a grounder for his eighth save.

“I was frustrated with the umpire, frustrated with myself,” Gardner said. “Maybe I let my emotions take over a little too much.”