Added null checks for pulling pages and posts by category.