The 4 code snippets in this tutorial enable you to style each post or page differently. To do this, you simply add some PHP code to your child themes functions file and create a custom field and add the CSS to the custom fields value field like you see in the following image:
This enables you to store the CSS rules in the value field of each post.page edit screen which only apply to 1 specific page or post. No need to use the post or page i.d in your stylesheet which would be very time consuming to manage.
You can also code it so you only need to add the value for 1 CSS property to the custom fields value field rather than add the entire CSS rule which is already added in the custom PHP code like this:
If you inspect the element, you’ll find the inline CSS has overridden the CSS from the child theme’s style.css file as you can see in the following example:
Here’s the code for logged in members:
Leave a Reply
You must be logged in to post a comment.