WordPress Categories in data-groups July 20, 2022 by Tarik Billa Just remove the trailing comma with some good ole php before echoing it out. $thelist = rtrim($thelist, ',');