How can I change the css of a post along with the theme?
January 14, 2009 5:32 AM
Subscribe
Using Wordpress, how can I call CSS for a post from a specific file, rather than having the CSS embedded within the post?
Situation: I write a post, and have some text highlighted in a certain colour that matches the theme (for example). When I change the theme, the colour of the text no longer matches.
Idea: use a .css file for each theme that contains the CSS for the posts, and call the necessary font colour/size etc from that, instead of having it within the post itself. Sort of like a theme for posts, instead of the whole site. When the theme changes, I can quickly change the post .css file to the correct one, and have the changes reflected in the posts when they are viewed.
Problem: I have no idea how to do this. I have a vague idea of how to create a .css file, and can probably work that out. What I want to know is what to put in the post html to ensure that the correct .css file is called, per theme. At the moment, I have [span style="color: #5a008c"] - obviously with different brackets. I want to be able to have ["path to file" "correct section" "whatever"] instead, that will give me the same results as above.
How do I do that? What syntax do I need to put in a posting to make it call the correct .css file?
posted by Solomon to computers & internet (3 comments total)
However, you can achieve this by creating your own custom stylesheet and adding it to your wordpress installation through a plugin, like this one. Then, you just need to apply the css class to your text through span tags.
For example, you could have a custom css stylesheet with:
.highlightedtext { color: #000; }
Then, when you're editing your post and want to highlight some text, just add
<span class=".highlightedtext">text<\span>
posted by Memo at 5:57 AM on January 14