Two planets can have the same orbital period without having the same orbit.
As you know, the orbit of a planet traces an ellipse, of which the circle is a special case.
What is necessary for two planets to have the same orbital period is that the semi-major axis of the ellipse for both has to be the same, and this will hold true regardless of the eccentricity of the orbit.
For the earth, having an orbit which is nearly a circle, the distance of the Earth to the sun can be considered to be the semi-major axis, and that the sun is at one focus ( or both foci ) of the Earth orbit.
The other planet would need an orbit of higher eccentricity, with the sun being again one focus of the orbit, but not the midpoint of the major axis. At times during the orbit the planet would be closer to the sun than the Earth and at other times farther away.