What do you do if you're president?
Do you show up for the photo op where the parents of the soldier slap you in the face for losing their son/daughter, or;
Do you show up for the photo op where the parents hug you and thank you for doing what you are doing, because their son/daughter was proud to serve and die for their country?
Which case would make you angrier? It's a no-win, because in the former case political enemies will use it for fuel to help their "War for Oil" diatribes, in the latter political enemies will suggest it is fake or staged. Don't pretend for a second it wouldn't happen.
Such a question as the thread opener suggests it's a simple matter to attend funerals of fallen soldiers, that there are not people ready to make an adversarial statement about it one way or another. Now personally in these situations I say, "Screw 'em, do what is right", but what is right? Attend a funeral for someone you don't know and act as though you really cared about them, or don't and be perceived as uncaring?
Now if someone is buried in a national cemetary such as Arlington, yes by all means the president should be there. If on the other hand it isn't such a ceremony, I'd leave it to the president's descretion as to whether or not he should attend.