WordPress Theme – Sidebar

March 10th, 2009 | Author: Sunny

In WordPress, there are widgets such as calender that may appear on your theme based on your appearance setting. Usually they will appear on sidebar when you add the widgets in the theme. If there is no widget adding to the sidebar, a function dynamic_sidebar() will return a FALSE value. This function is useful if you are designing a theme template because you may want to create something if there is no widget on the sidebar. For example, you may want to include your own widget to the sidebar if user has not included any widget in the theme appearance setting.

Further, if you want to add widget at the appearance setting, you will need to register the sidebar to WordPress in the file function.php. The function register_sidebar() will tell the plugin that your theme will need exactly one sidebar and your admin inteface should have Sidebar Widgets in the Presentation menu. register_sidebar() also allows you to decorate the widget by adding a parameter to it. For example,

<?php
if (function_exists(’register_sidebar’) )
register_sidebar(array(’before_widget’=>’ ‘,
‘after_widget’ => ‘ ‘,
‘before_title’ => ‘<div class=”title”>’,
‘after_title’=>’</div>’));
?>

before_widget and after_widget means that something that you want to decorate the widget.. you may think it can be a warper and you will warp your widgets. In this example, we put nothing, so there is no decoration for this widget warper. Then before_title and after_title, will decorate the wiget title with <div lass=”title”> and </div>. The output will look like this:

<div lass=”title”> Widgets Title </div>

What if you want to include more than one sidebar? Then instead of using register_sidebar(), you will use register_sidebars(n) where n is the number of sidebars. (starting with 1)

For more information, you may check out this page to see how to widgetizing themes with sidebar.
http://codex.wordpress.org/Widgetizing_Themes


WordPress Theme – WordPress Loop

March 08th, 2009 | Author: Sunny

WordPress Loop is the Loop that is used by WordPress to display each of your blog posts.  Using the Loop, WordPress processes each of the posts to be displayed on the current page and formats them within the Loop tags.

Basic WordPress Loop structure will look like this:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<!– something you want to repeat within the Loop tag –>
<?php endwhile; else: ?>
<p><?php _e(’Sorry, no posts matched your criteria.’); ?></p>
<?php endif; ?>

Let me explain what is going on. First, you need to know that there is a global object called $wp_query, and when WordPress generates your blog pages, it will build and execute a DB query that results in an array of posts, and which will store in the $wp_query object and also return back to the blog header where it is stuffed into the global $post array.

The have_posts() actually calls $wp_query->have_posts() which checks a loop counter to see if there are any pots left in the post array and return a boolean value TRUE if there is post or FALSE when we have exhausted the loop. And the_post() calls $wp_query->the post() which advance the loop counter and sets up the global $post variable as well as all of the global post data. On the other hand, It takes the current item in the collection of the posts and makes it available for use inside the iteration of the Loop.

Once you understand how the WordPress loop works, then you can use this loop for displaying your blog posts. So, here are some functions that you probably will put inside the WordPress loop:

the_title() – Display the current post’s title

the_time(format) – Display the date with format

the_author() – Display the author name

the_permalink() – a Permanent Link that point to the current post

the_content() – Display the content of the post

There are more technique you can use and display inside the loop. Here I just post some common functions that you will usually use, but there are more function you can do such as comment for the post. You can find more information here:

http://codex.wordpress.org/The_Loop
http://codex.wordpress.org/The_Loop_in_Action

Category: WordPress | Tags: , , | 1 Comment

White Balance – Photography

March 06th, 2009 | Author: Sunny

I went to my first photography course yesterday. White balance was something that I don’t really understand how it worked before… but I got some idea now. I may be wrong, but I am going to demonstrate here:

my D700 can adjust color temperature for 2500K to 10000K. Today it is a cloudy weather. I found about 5000k-6000k probably is the right color temperature setting for today.  I will use 5000k for comparison in this experiment.

5000k:
p-4


I also tried 2500k, 4000k, 8000k, and 10000k (remember the color temperatures here are  the white balance setting for my camera, so don’t be confused with the real color temperature for this cloudy day) :

2500k:
p-1

4000k:
p-5

8000k:
p-3

10000k:
p-2

Color temperatures is like this:
The lower the color temperature, light spectrums shift to contain more orange or red wavelengths.  In contrast, the higher the color temperature, light spectrums shift to contain more blue wavelengths.  As the color temperature rises, the color distribution becomes cooler.

Result:

In this experiment, the correct color temperature is 5000k.  If my camera white balance setting for color temperature is lower than 5000k, my camera will absorb more blue light, and as result my photo will become blueish.   (because the camera thinks that the color temperature is low.)

On the other hand, if my camera white balance setting for color temperature is higher than 5000k, my camera will absorb less blue light, and as result my photo will become reddish.   (because the camera thinks that the color temperature is high.)

Pretty simple concept.  If you want to learn more about white balance, I found the site has much better explanation how white balance setting and color temperature works.  the URL is: http://www.cambridgeincolour.com/tutorials/white-balance.htm