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.
Jan
23
2009

Make a static homepage

The homepage of this site was created using the default page template but I inserted a custom style sheet, only for this page, in the custom_functions.php file. I’ll show you how I did it in the following steps…

I created a blank page and used the default template in the attributes section. Go to Page —-> add new123

Click “Publish”, and now you have a blank canvass to build your homepage from.

Next in my custom_functions.php I created a style sheet just to style this page only…

In your custom_functions.php file add the following code. You can put it anywhere you want but I recommend putting it at the top after the <?php tag. Remember, once you make the change, save it, and upload it to your server. Always describe the function and put it between the comment tags /* */ at the beginning shown below in green. The comments aren’t shown on your rendered page and it just makes things easier for you to remember…

/*my homepage stylesheet*/
function welcome_stylesheet(){
if (is_front_page()) { ?>
<style type=”text/css”>
#content_box {margin-top: 36em; background: none;}
#content .top {margin-top: 13em;}
#sidebar_1 {margin-top: -2.6em;}
#sidebar_2 {margin-top: -4.5em; }
#content {background-color: #ffee99; padding-top: 1em;}
/*This nudges the teaser content up against the right sidebar*/
#column_wrap {width: 77.3em; background: none;}
#sidebar_2 li.widget {background: #ffeeee; padding:0 0 .5em .5em; width: 103%; margin-top: 1.7em; margin-bottom: -.8em;}
</style>
<? }}
add_action(’wp_head’ , ‘welcome_stylesheet’);

If you want to see how I placed a custom box on the homepage, check out this tutorial

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...

{ 3 comments… read them below or add one }

Joe May 19, 2009 at 2:33 pm

So I create a new page, then I insert that code into the specified file and nothing happens…. How does the creation of the page and the insertion of the code connect? How do I make a front page static? For example, if I create a new page, how do I then make that page my homepage? Thanks in advance. Great site, learned a ton.

Reply

Nasty May 19, 2009 at 5:47 pm

What was the page you created? Was it your home page or another one. Check out the conditional tag in the function. The
if (is_front_page()) might have to be changed. If it is the home try adding this to the conditional tag…

if (is_front_page()) || (is_home())

To create a page and make it the home page create your page and publish it. Then go to Settings—Reading—and you’ll see a drop down list of pages that you can make your home page.

Reply

Joe May 20, 2009 at 1:24 pm

Yea… I avoided adding any code. Just made a page, then went to settings->reading->, there I selected my new static pageto be the home page. Thanks.

Reply

Leave a Comment

Previous post: Put an ad in your post

Next post: Remove the sidebar line