I'm replacing a ceiling fan with a regular light fixture. The fan was connected with black to black, white to white, and a red wire to a blue wire in the ceiling fan. When I connect the new fixture, just a plain two bulb light fixture, black to black white to white and cap the red the light will not shut off from the wall switch. There was no ground from the fan fixture, but there is from the new one which I connected to the ground on the mounting bracket. So I expect the red wire runs to the switch, but how do I connect it to the light fixture - which wire connects to which wire? Red to black and cap off the black (there are two coming down) to each other in the ceiling? and white to white?
... it was supposed to be a comment but I don't have enough rep to do that.
It looks like you have connected the 'live' of the former fan (that almost surely was turned on by pulling a cord) to the 'bulb' cable.
My suggestion is open the wall switch and taking note of colours: you have to connect to the light fixture the cable of the same color as the one coming from the switch
... my guess is that red was coming from the switch and black was the fan's 'live'. so just swap back with red and all should work (at worst the light won't lit)
PS: remember to insulate the unused cable
EDIT: my guess was right: black is the live (from brakers) and red is the swiched line. swap black cable (on the fixture) with the red one and your issue willbe solved
SO: White: neutral (common)
Black: Live (uninterrupted) - not to be connected for lighting
Red: Live (interrupted by the switch)