When a creature is declared as an attacker or a blocker, they remain an attacking or blocking creature until one of there things happens. The first is that they are removed from the battlefield in some way. The second is that the creature would be destroyed but is regenerated. (In this instance it will remain in the battlefield, become tapped and have all damage removed from it.) The third way that a creature stops being an attacking or blocking creature is when the combat phase ends.
While it is often glossed over, the combat phase does not end immediately after combat damage is dealt. After the combat damage step there is an end of combat step. It is when this step ends that creature leave combat. Abilities that trigger when a creature in combat deals damage, or has left the battlefield due to lethal damage will go on the stack in the combat damage step.
Vengeful Pharaoh has a triggered ability that triggers when the Pharaoh is in your graveyard and you or a planeswalker you control is dealt combat damage. If this ability triggers, it will go on the stack in the combat damage step. The Pharaoh’s ability targets an attacking creature, and as mentioned above creatures that were attacking will still be doing so at this point.