As described previously…
K_{a}=\frac{[A^{-}][H^{+}]}{[HA]}
Take the logarithm of each side…
logK_{a}=log[H^{+}]+log\frac{[A^{-}]}{[HA]}
Subtract log [H+] from both sides to move it to the left…
logK_{a}-log[H^{+}]=log\frac{[A^{-}]}{[HA]}
Subtract logKa from both sides to move it to right…
-log[H^{+}]=-logK_{a}+log\frac{[A^{-}]}{[HA]}
Rewrite to express as pH and pKa …
pH=pK_{a}+log\frac{[A^{-}]}{[HA]}