Archive for April, 2008

CHAPTER 17 CUSTOMIZING YOUR BLOG S (Web design rates) LAYOUT 485

Tuesday, April 8th, 2008

CHAPTER 17 CUSTOMIZING YOUR BLOG S LAYOUT 485 Listing 17-16 shows the complete code for sidebar-c.php. As with the get_posts call, if you pass the variable containing the current category as a parameter to the function, the function will output a list of links from that category. Listing 17-16. Complete sidebar-c.php cat_ID; $posts = get_posts(’numberposts=10&category=’ . $cat); ?>

Although this function can take a long list of parameters specifying how many links are displayed, what information from each link is output, and so on, it is easier to use the Link Categories tab of the Links page, shown in Figure 17-23, to control the output. The values and options you set there are used by wp_get_links.
In case you need quality webspace to host and run your web applications, try our
personal web hosting services.

484 CHAPTER 17 CUSTOMIZING YOUR BLOG S LAYOUT (Web server application)

Monday, April 7th, 2008

484 CHAPTER 17 CUSTOMIZING YOUR BLOG S LAYOUT example, you deal with only the first category from the list. I have set my sample blog to use only single categories per post. Listing 17-14 shows this first step. Note It is quite natural to have multiple categories per post. The code would need to be more sophisticated to handle that situation. It may be easier to use a plug-in like Related Posts by Mark Ghosh (http:// weblogtoolscollection.com/archives/2004/06/08/contextual-related-posts-in-wordpress/). Listing 17-14. Saving the First Category from the Post in sidebar-c.php cat_ID; ?> Once you have the category ID, you can use it with another standard template function get_posts. Not surprisingly, this function will get a list of posts. If you pass in the category ID from the last step, via the variable, the function will return a list of posts in the given category. Add an extra parameter to limit the number of posts returned. Once you have that list of posts, you can loop through the list, extracting the link to the post and the post title. Output them as an HTML link in an unordered list. Listing 17-15 shows the completed code with a header and a class style specified or the list. Note that because it uses the category from the current post, this list will also be in the same category. Listing 17-15. Generating the List of Posts in sidebar-c.php cat_ID; $posts = get_posts(’numberposts=10&category=’ . $cat); ?>

Web design software - CHAPTER 17 CUSTOMIZING YOUR BLOG S LAYOUT 483

Sunday, April 6th, 2008

CHAPTER 17 CUSTOMIZING YOUR BLOG S LAYOUT 483 Figure 17-21. Creating a link Figure 17-22. A partial list of links A New Sidebar:Tying It All Together Now that you have a list of links in the same category as the article in this example, you can see how it all fits together. In the new sidebar code, you first need to find the category of the current article. A standard template tag helps you with that: get_the_category returns a list of the category IDs for the current post. Save the first category ID in a variable, $cat. For this
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

482 CHAPTER 17 CUSTOMIZING (Zeus web server) YOUR BLOG S LAYOUT

Saturday, April 5th, 2008

482 CHAPTER 17 CUSTOMIZING YOUR BLOG S LAYOUT a good idea to create both sets of categories at the same time. This will allow you to do some clever things in your theme code, as I will show you shortly. Figure 17-20. Link categories Once you have created your link categories, you can start adding links and assigning them to the categories. Figure 17-21 demonstrates adding a new link. You can supply the URI, a name for the link, a brief description, and assign a category. If the link is to someone you know, you can designate an XFN relationship. Further down the page, you can also assign an image to the link, specify an RSS feed associated with the link, assign a rating, and even add substantial notes to the link. Note XFN, for XHTML Friends Network, is a simple way to represent human relationships using hyper- links. See http://gmpg.org/xfn/ for more information. Figure 17-22 shows a small selection of links in the list management page. You can see one of the original blogroll links and several added to the Information Architecture category. (Not all of the sites listed are really about information architecture; they are purely for illustration.)
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

Web hosting reviews - CHAPTER 17 CUSTOMIZING YOUR BLOG S LAYOUT 481

Friday, April 4th, 2008

CHAPTER 17 CUSTOMIZING YOUR BLOG S LAYOUT 481 For the layout s one sidebar, you could add more code to one of the existing sidebar files to include the information you want. But for this example, let s add a completely new sidebar. Create a new building block sidebar-c.php to use in the layout by copying sidebar-b.php. Listing 17-13 shows index.php. Similar to the code for the other sidebars, you test for the blog displaying a single page and change the main content width appropriately. You then use the single-page test to choose whether to include the new sidebar or both the old ones. The result is that on single pages, the new sidebar is displayed, and on all other pages, both sidebars A and B are displayed. Listing 17-13. Adjusting the Layout Based on the Single-Page Test in index.php

Sidebar C will contain almost all new content. The reader will want recent articles in the same category available as a possible next destination. Also, a list of links to external related resources is a valuable addition to the page. You can use WordPress s built-in Link Manager to collate the list of links. So, let s take a brief side trip to the Link Manager, before continuing with the new sidebar. A Digression: Using the Link Manager WordPress comes with a powerful Link Manager, which allows you to create lists of links as part of the content of your blog. If you remember from the history covered in Chapter 13, lists of links to other sites, or blogrolls, are one of the essential parts of a traditional blog. Click the Links menu in the administration pages to start managing your links. WordPress comes with a small list of links already built in. These link to some of the members of the WordPress team and are in the Blogroll category. Link Manager categories are separate from your post categories, but it can be a good idea to keep them pretty much in sync. Figure 17-20 shows the link categories in my sample blog. Apart from category 1, Blogroll, all the categories match the post categories in name and number. Because you cannot control the number a new category is given when you create it, it is
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.

Cool web site - 480 CHAPTER 17 CUSTOMIZING YOUR BLOG S LAYOUT

Tuesday, April 1st, 2008

480 CHAPTER 17 CUSTOMIZING YOUR BLOG S LAYOUT Next comes some style tweaking. To do something more attractive with the images, which otherwise display sequentially in the text, add two rules to allow you to float images to the left or right as you feel appropriate. Floating an image in this way allows the text to flow around the image. Add a margin to prevent the text from flowing too closely to the images. Also add two .storycontent rules to adjust the margins of the article paragraphs and headings to add a little more white space to the article. If text is too dense, it can be hard for your visitors to read. Listing 17-12 shows the new rules added to the style sheet. Listing 17-12. New Style Rules in styles.css .imageleft { float: left; margin-right: 1.5em; margin-bottom: 0.5em; } .imageright { float: right; margin-left: 1.5em; margin-bottom: 0.5em; } .storycontent p { margin-bottom:0.75em; } .storycontent h2 { margin-top:1.5em; margin-bottom:0.5em; } In order to choose which way an image floats, you just need to add the appropriate class attribute to the image tag in the article. Figure 17-19 shows the code in the article, in this case floating an image to the left. Figure 17-19. The class in the tag will cause the image to float left.
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.