November 16th, 2008 · 1 Comment
I have installed the Intense Debate plugin for handling comments on this blog. Not that there are that many comments , just to see how it works. I think it’s nice that it automatically synchronizes comments two ways to the regular WP comments, so that if you disable it, all the comments are still there.
Let me know if you have any comments, or if you find anything broken.
Tags: Site news · wordpress
I am not a political person, this is not a political blog, and I am not a U.S. citizen, but like many others, I have watched this year’s U.S. presidential election with much interest, and I am very happy that Obama has won. I just want to post something quick with some of the interesting media I have seen during yesterday and today.
[Read more →]
Tags: obama · politics
November 3rd, 2008 · 8 Comments
I saw an article on wprecipes.com describing how to display a random header image in a Wordpress blog. While the code shown works, it is a bit verbose and hard to maintain, so I thought I’d show how the random image in the header of this blog is done.
Note: you may need to adjust some of this to the specifics of the theme you are using, but the base mechanism is the same.
In this technique, the assumption is that you have a directory with header images, located in images/headers under your theme directory (e.g. /your/blog/directory/wp-content/themes/yourtheme/images/headers/). The code shown below will choose an image at random from this directory. The images should already have the appropriate size/ratio to be shown in your blog.
Here’s the code, to insert instead of the existing <img> tag for your theme’s header image (most likely in header.php):
<?php
$curdir=getcwd(); chdir(get_template_directory() . "/images/headers");
$files=glob("*.{gif,png,jpg,gif}", GLOB_BRACE);
chdir($curdir);
$file=$files[array_rand($files)];
?>
<img src="<?php echo(get_bloginfo('template_url')."/images/headers/$file"); ?>" width="770" height="140" alt="<?php bloginfo('name'); ?> random header image" />
Some things you may want to change:
- The location of your images (if not under images/headers in your theme directory)
- The size of the header images in the img tag
- The filter for the images in the glob statement (currently it will grab any gif, png, jpg or gif files in that directory)
I’m not an expert PHP developer, so there may be a more efficient way of getting a random file from a directory, I’d be happy to learn about it.
Tags: Blogging · howto · themes · wordpress