This question already has an answer here:
After Book 6, when Snape killed Dumbledore, as per the magical law every Hogwarts headmaster/headmistress gets his/her portrait in the headmaster's office. This was known to Harry and obviously he was aware that Dumbledore will have his portrait in the headmaster's office as well.
We also know that portraits of the headmaster can travel between their portraits outside the headmaster's office as well. For instance, Phineas could travel between Hogwarts and Grimmauld Palace. Similarly, Dilys Derwent can travel between Hogwarts and St. Mungo.
We also know that headmasters in the portraits can travel between the portraits irrespective of the actual location of the portrait. For instance, when Hermione took out Phineas portrait from Grimmauld Palace and put it in her purse, she was able to interact with it when needed. Moreover, Phineas was also able to listen to their conversation whenever the purse was opened.
Now this seems very far fetched that Dumbledore didn't discuss about this with Harry when he was giving him lessons in Book 6. Dumbledore knew perfectly well that he had only few months left and Harry will definitely need his help and guidance when he will be hunting the horcruxes.
Why didn't he advise Harry to keep a portrait of him along with him in case something happens to him?
This seems like a convenient flaw in the plot to make the horcrux hunting a lot more laborious work than it actually was.
Furthermore, why Harry couldn't think of this when he started hunting the horcruxes in Book 7?
He knew perfectly well that he had absolutely no idea about the location of the horcruxes let alone what to do with them and how to destroy them when he found them. That was the reason the trio kept on dangling the locket in their necks for months long. It could have been a lot easier and much better approach to get the portrait of Albus Dumbledore along with them and getting advise from it wherever needed.