'the king' is a position, 'King Bob' is a title. Like 'my mum' is a person, but 'Mum' is a name (of sorts). That's how I've always thought of it anyway.
Yes, I agree with the Mum thing, but why "the king" but "the Pope" or "the Duchess of Argyll" but "the duchess" (presumably). Does it capitalise when there is only one?
Edit: found
this on Google, which is probably what I should have done in the first place. In particular:
3.Titles and office
As a general rule when a high-ranking title occurs before a name, it is capitalized. When the title follows the name, it is usually lowercased, except for the U.S. President and other very high officials. In most other cases a title standing alone is lowercased. In the case of a long or unwieldy title, reorganize the sentence structure so that the title follows the name
(So, "the king" but "King Bob")
And:
8.Honorifics are capped: His Eminence, Your Majesty, Her Majesty, Excellency, Her Royal Highness, Your Royal Highness, Your Honor, Your Grace, My Lord, His Lordship -- but: yes, sir
If we accept that one can't go far wrong by following the National Geographic style manual, the original passage becomes:
I went to visit the king of Bogna, King Fred. 'Have a care, Your Holiness My Lord Abbot, for His Majesty has a nasty case of Tesco claret,' said one of the king's courtiers.
Though this does look a little ... unwieldy.