Thread Starter
mthant
(@mthant)
No, I mean to ask where I shall write if I want to write CSS in 2016 theme just for a single page. I know it is not a good idea to write javascript or CSS for the whole site. That it can be wiped out when WordPress is updated. But I just want to write CSS for that one single page.
Is there a CSS editor for that?
That it can be wiped out when WordPress is updated.
That’s true for every theme; if you edit the theme files directly your changes will be lost when you update the theme.
To add custom CSS:
– If you have a child theme you can add the CSS to the style.css file.
– If you are using WordPress 4.7+ you can use the “Additional CSS” option in the Customizer.
– If your theme has a custom CSS option you can use that to add the CSS.
– If you have Jetpack installed you can enable its Custom CSS module.
– Otherwise you can install a plugin like https://wordpress.org/plugins/simple-css/.
To apply CSS to a specific page you can use the page id class from the <body> element. You can get that in one of two ways:
1. In your Admin > Pages > All Pages list, hover over the page title. At the bottom left of the browser window you’ll see “…post.php?post=xxx…” where xxx is the id.
2. While viewing the page in your browser, use the inspection tool, go the the <body> tag and you’ll see “page-id-xxx”.
In your CSS, use the page class like so:
/* change page text to black */
.page-id-xxx {
color: #000;
}
-
This reply was modified 9 years, 2 months ago by
bdbrown. Reason: corrected tag id