Free web hosting music - CHAPTER 17 CUSTOMIZING YOUR BLOG S LAYOUT 469

CHAPTER 17 CUSTOMIZING YOUR BLOG S LAYOUT 469 Listing 17-8. Using the Class Variable in main-content.php

A Conversation Layout Now that you have your building blocks in place, you can make some decisions about which pieces to use in appropriate circumstances. This first example demonstrates a layout to satisfy the readers who want to go straight to the conversation and join in. A Single-Post View WordPress has a template function that tells you if the page you are viewing contains a single post: the is_single function. You ll use that template function to decide to exclude the sidebars and allow the post and comments to fill the width of the template. Listing 17-9 show the modified code to make this happen. Listing 17-9. Testing for a Single Page in index.php

Notice a couple of big changes here. First, all the PHP code is inside one block. You don t need to include each line of PHP inside its own tags. You can amalgamate multiple PHP lines. This works well in this case because there is no longer any HTML code mixed in. Second, you use the WordPress template function is_singleto test if the reader is viewing a single post. If the function returns true, then you set your CSS class variable to main-content-full. If it is not true, the else part of the clause is executed, setting the CSS class variable to the normal main-content-norm. The main-content building block isn t included. Then you test again whether you are viewing a single page. This time the test is negative. The exclamation mark in front of the is_single function negates the test. This test means, If the page is not a single
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.

Leave a Reply