I will start by looking back to the design of dye sensitized solar cells, DSSCs.
1. a transparent conductive glass or plastic, then you deposit n-type semiconductor (like TiO2) or p-type semiconductor (like NiO).
2. a material that can absorb the majority of the photons that come the sunlight and convert them to useful work; electricity. This is a dye. The dye will fill the pores of the semiconductor.
3. a material that can facilitate the transportation of the charges and regenerate the oxidized dye. This is an electrolyte like iodide/triiodide one.
3. a material that can re-generate both the dye and the electrolyte in order to keep the DSSCs work. This is the counter electrode like Pt
The photons coming from the sunlight will be absorbed by the dye. This will cause excitation of the dye molecules to higher energy level (from HOMO to LUMO level). The excited electrons (negative charges) from HOMO to LUMO level will leave vacant places, called holes (positive charges). Those negative and positive charges need to go to different places, otherwise they will recombine and the result is nothing.
So you need to consider something else called "energy levels" to design your DSSCs.
In the case of TiO2 DSSCs, LUMO level of the dye need to be higher that conduction band (CB) of TiO2 to inject the electrons to it. However, if LUMO is lower than CB of TiO2 then electrons will not be injected and will recombine with the holes. Consider the attached image.
The function of TiO2 is to facilitate the transportation pathway of the injected electrons from the dye to the transparent conductive glass/plastic as well as to reduce the energy barriers.
In addition to that said by he colleagues above, there is an additional function where a TiO2 with bores has the so called scaffold function which means that it acts as a structure to support the thin die. The die layer is so thin that it is not able to sufficiently absorb an appreciable part of the incident solar radiation. To increase the effective absorption thickness along the die, it is deposited on TiO2 layer with bores. THE die itself is made thin because the excitons have specific diffraction length which is of the order of 10 nm while the required absorption length is about underfeeds of nanometers.