Complex sentence: In the reign of King Rama IV, he was promoted to be the director of department of royal scribes, which was the last post he held in the court, and with which he earned the title "Phra".
Split into simpler sentences: In the reign of King Rama IV, he was appointed to the post of director of the department of royal scribes. This was the last post he held at court, and the one in which he earned the title "Phra".