free hit counters
If you are using Internet Explorer as your browser please be running at least IE 7 or above. This site does not support IE 6 or below. Go here for the latest free version including easy download and installation instructions If you want to make it real easy on yourself, download Firefox , the most popular browser in the world. It's free and simple. You'll be so glad you did.
Mar
1
2009

Add a unique style sheet to your homepage

You can make your homepage look totally different from the rest of your site by adding a unique inline style sheet, just on the homepage, through your custom_functions.php file…

The inline style sheet can be styled right in the functions file instead of the custom.css file. Here’s a real simple example.

First create a function and name it whatever you want…

function homepage_stylesheet () {
}

Next, run that function only on the homepage and turn off PHP by adding the following…

function homepage_stylesheet () {
if (is_front_page)) { ?>
}}

Next, add an inline style sheet…

function homepage_stylesheet () {
if (is_front_page)) { ?>
<style type=”text/css”>
</style>
}}

Next, turn PHP back on and add the style sheet to the head of the page with a hook…

function homepage_stylesheet () {
if (is_front_page)) { ?>
<style type=”text/css”>
</style>
<?php
}}
add_action(’wp_head’ , ‘homepage_stylesheet’);

Finally, you add whatever styles you want between the opening and closing tags of the style sheet. For example say I wanted to make the content area of just the homepage black I could add this code….

function homepage_stylesheet () {
if (is_front_page)) { ?>
<style type=”text/css”>
#content {background-color: #000;}
</style>
<?php
}}
add_action(’wp_head’ , ‘homepage_stylesheet’);

Leaving a comment with code in it...

If you would like to leave a comment and you have examples of code you want to show, you must "escape the code". This allows the entire code to show correctly by inserting certain variable around certain tags to make them show. If you don't "escape the code" your code will show up broken, mangled, and it won't be able to be seen correctly. "Escaping the code" is very simple...

  1. Copy your code you want to show
  2. Click here to go to the site to escape the code
  3. Follow the directions, it's so easy
  4. Once you have the escaped code copied, paste it in the comments area where you want
  5. Now you can enjoy life


Go ahead, leave a comment...

Leave a Comment

Previous post: Lightbox 2 plugin

Next post: Change comments appearance