Vertically aligned CoFe2O4 and 10% Mn-doped CoFe2O4 nanowires were synthesized by the gas-phase reduction/substitution reaction of pregrown alpha-Fe2O3 nanowires. They consisted of perfect single-crystalline cubic structures grown along the  direction. The increase of the lattice constant provides evidence for the effective Mn substitution. We investigated their electronic structures using X-ray absorption spectroscopy and X-ray magnetic circular dichroism. The results suggest that as the Mn substitutes, Mn2+/Mn3+ ions would occupy the octahedral (O-h) sites, Mn4+ ions form at the tetrahedral (T-d) sites, and a fraction of the Co2+ ions migrate from the O-h sites to the T-d sites. The effective Mn substitution can increase the hole concentration, which makes it possible to develop humidity sensors operating at room temperature. Furthermore, it induces high photocurrents upon irradiation of visible light.