A more direct translation of the Hebrew has the sons of David serving as priests (see ESV, NASB). The NIV has claimed that they were royal advisers on the basis of 1 Chronicles 18:17. It is possible that the sons of David served as priests on account of the fact that David himself held such an office (see 2 Samuel 6:14, 2 Samuel 6:18; Psalm 110:4).1 We also read of them performing priestly actions in their rebellion against David (Absalom in 2 Samuel 15:12 and Adonijah in 1 Kings 1:9, 1 Kings 1:19).2
18 and Benaiah the son of Jehoiada was over the Cherethites and the Pelethites, and David’s sons were priests.