How should a person pray who wants to offer the funeral prayer over more than one grave?.
With regard to offering prayers over graves, one of two scenarios must apply:
1. Either the graves are in front of the worshipper, in the direction of the qiblah in one line, in which case it is valid for him to offer one prayer for the occupants of all of these graves;
2. or the graves are scattered, with some of them on his right and some on his left, in which case each grave has its own ruling, so he should offer the prayer at each grave on its own.
Shaykh Muhammad ibn ‘Uthaymeen (may Allaah have mercy on him) was asked: There are two janaazahs (funeral biers) next one another in the graveyard: how should the prayer be offered for them after burial? Should the funeral prayer be offered for each janaazah on its own, or can the intention be made to offer the prayer for both? He replied: If the graves are both in front of the worshipper, then he may offer one prayer for both, but if each one is in a different place, then he should offer the prayer for each one (separately). End quote.
Majmoo’ Fataawa Ibn ‘Uthaymeen (17/159)
The one who is offering the funeral prayer over a grave should stand with the grave in front of him like the bier is in front of the worshippers during the funeral prayer. If the deceased was male, he should stand at his head, and if the deceased was female, then he should stand at her middle.
And Allaah knows best.