Archived topic
CSS and php in a page or post
5 replies · Started by Tony on January 30, 2016
The many solutions you provide the css for override the css in the theme and apply to the whole theme I think?
Is there a way to apply a change to the css on just one page? i.e. Can I use <style> to modify a css definition in a page?
If so where would that be placed? At the very top?
I guess though that the visual editor would strip it out if you ever used it on the page?
Resolved - I should have tried it before I asked Doh!
Example:
<style type="text/css">
<!--
h1 {
font: Droid-Sans;
font-size: 30px;
font-weight: 500;
margin-bottom: 20px;
line-height: 1.2em;
}
-->
</style>
Hi there,
I don't suggest doing it this way.
CSS should be placed within the <head> section.
Take a look at this plugin: https://wordpress.org/plugins/wp-add-custom-css/
Thanks for the pointer. I've had a look but before I consider yet another plugin:
I currently have two places where I have custom css - 'simple css' and 'edit css' which is part of Jetpack.
I'm not sure how they work i.e.
- Does one of them override the other if they contain conflicting code?
- Could I combine the code into one of them - if so which one?
I like the idea of custom css in an individual page/post but with another plugin I would have yet another place for custom css and presumably another call to the database for it even if there's nothing in it?
I would rather go for Simple Custom CSS and just use the !important tag for what does not work.
If you have Simple CSS, you don't need Edit CSS from Jetpack.
The plugin I linked to allows you to add CSS for specific pages - it will make one more call to the database, but you really shouldn't notice any difference.
This is a good idea for a future update in Simple CSS - it would help a lot of people I think.
