0

I'm currently customizing a theme in WordPress and was wondering if it's safe to use the WordPress generated classes in my CSS.

For example, is it okay to use .page-id-105? Is there any chance that the ID could automatically be changed in the future by WordPress and then re-indexed?

2 Answers 2

2

Post ID Specific Classes are not reliable at all. The ID is based on when the page was created ( in what order since IDs auto-increment ). If the user "accidently" permanently deletes the page and needs to recreate it the page will have a new ID and thus not use any of the predefined styles. The best bet would be to use a Custom Page Template so the user can assign it to a specific page. This is probably the most user-friendly method.

0
0

if you want to attribute styles to certain pages, what i do is create a custom template and insert a custom id or class directly hardcoded in the template elements, this way it will not change overtime on it's own or by user accident (except if the user changer the template).

If you still want to apply styles to .page-id- classes you can use [class^="page-id-"]{color:#fff} this style will apply to all class elements starting with page-id-

Edit: just realized you already talked him about templates, sorry...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.