Joint issues
Your guinea pig may also walk strangely if it has arthritis which is an inflammation of the joints and soft tissue in the guinea pig. Typically this would be the case for piggies over the age of 6 years or more. However, it could be found in younger piggies if they have had previous injuries or born with deformities. There is also other conditions like osteo dystrophy found in Satin guinea pigs that can be debilitating.
Guinea pigs with arthritis can take pain medications but they need to be prescribed by the vet. Making sure your guinea pig is not exposed to any cold or heat extremes is also a must as a piggie with this, already has a compromised immune system and joints that are already swollen and sore become more painful in the cold conditions.
Injury
Lastly your guinea pig may have sustained an injury. Occasionally they will leap on and off hidey holes and other items. As they have a more brittle bone structure than other animals, they may have mistaken the jump and hence caused a pain to a limb. If this is the case the main concern is that of a broken bone. If you think this is possible then vet treatment again is required immediately.