you can manually unlock the tailgate by accessing the lock mechanism through a small hole provided on the interior trim. you will see a small plastic plug that covers up the hole which is near the middle of the tailgate.
the cause of unlock/lock trouble - could be frayed/shorted wires in the wiring conduit which goes between the tailgate and the body. you'll see the rubber sock and grommet on the upper left (when standing behind the vehicle). this conduit, and wires within, flexes each time the tailgate is opened/closed. it is well documented on this site that failures occur inside the conduit. you may have to repair sections of the frayed wires manually.
Fan Clutch, Idler&Tensioner Pulley, Fuel Filler Hose, Camshaft Actuator, Trans Fluid, Shocks, Brakes, F/R Diff & TC Fluid...