Quickie: Executing CSS in custom_functions.php
Sometimes we need to execute CSS code within the PHP in our custom_functions.php file. It’s a simple trick! You use the style statement to wrap your CSS in.
Here’s an example for you:
function use_style_statement() {
?>
<style type="text/css">
.custom #some_id { background: #000000; }
.custom .some_class { position: relative; }
</style>
<?php
}
Note these things:
- You must turn PHP off with the
?>statement before using thestylestatement and back on with<?phpwhen you are finished. - The CSS statements within the
stylestatement are the same as you would use in thecustom.cssfile
Now, isn’t that easy?
I hope you are able to use this quickie in your code! As always, feel free to leave a comment below. If you want to contact me directly by email, just click the “Contact” tab in the menu.
©2009 Michael L Nichols. All rights reserved.
What next?
Your comments are always welcome, and are important to this blog’s community! Leave a comment now, or read the comments.
You can find several related articles in the “Related Articles” list below. In the footer you will find a lists of Popular Posts, Recent Posts, and you may browse by Categories, or tags. There’s also a Google Custom Search box to help you find just what you want.
Get free updates by RSS or email!
If you have enjoyed this article, please consider subscribing to article updates, using
an RSS reader, or
by email. It’s free and is a great way to make sure you don’t miss a single article! I also invite you to follow me on
Twitter!
Why not share this article with others!
Share this article with your friends using your favorite social media service, such as
StumbleUpon, or
Digg. Check out the icons below under “Share This Article With Others” for other social media, including del.icio.us, Technorati, Sphinn, Friendfeed, FaceBook, MySpace andLinkedIn! You can also email or print the article, and even tweet it using Twitter!











{ 1 trackback }
{ 1 comment… read it below or add one }
Simple and effective tip. But my blog readers find hard to use this as they are almost newbies to css and php. Anyway i am trying to help with them.