I would like to add a body class to my WordPress pages which should be usable to identify pages/posts/categories... I would then want to save that identifier class in the database and be able to add unique CSS code only to that specific page (no matter if it is a post/page/category/tag/archive etc.)
What I have thought so far without success:
- Use
get_the_ID()
for posts and pages, but what about all the other pages like archives, category pages, tag pages etc.? Are there even ways for every kind of content to get a unique ID? - Store the URL, but what happens once the user changes the permalink of a page / post or the domain?
- Get all currently available body classes of a page and combine them to create a CSS selector, but what happens if another class is added or a class is removed?
Does anyone have a different approach?