For the past couple of weeks, I suddenly had an urge to hang out at WordPress.org support forum. All I can say that it was a whole new experience. Reminds me a lot when I was active in K2 forum – answering question and request free of charge!
I think my WordPress ninja skill has been upgraded to another level.
Malaysia PlayStation®Store is officially launched – finally.

Some thing never change. Animated GIF FTW!
Does anyone know the easiest way for WordPress [gallery] to force x number of columns display without tampering the core or manually set the columns value to the shortcode?
I could only figure out 2 possible ways:
- function / code duplication
- Regular expression
If you use [gallery] shortcode without setting the columns value, the default is set to 3. Some WordPress theme can either fit 3 or more column per row or less. Below is an example to force [gallery] columns to 2 to any post or page that uses [gallery] shortcode:
function gallery_columns($content){
$columns = 2;
$pattern = array(
'/(\[gallery(.*?)columns="([0-9])"(.*?)\])/ie',
'/(\[gallery\])/ie',
'/(\[gallery(.*?)\])/ie'
);
$replace = 'stripslashes(strstr("\1", "columns=\"$columns\"") ? "\1" : "[gallery \2 \4 columns=\"$columns\"]")';
return preg_replace($pattern, $replace, $content);
}
add_filter('the_content', 'gallery_columns');
$columns can be set to any numeric value. If [gallery] columns is set to 0, no row breaks will be included.
There are probably some hidden drawbacks to the method above. Feel free to share if you have any other solution.
I hate to admit this but if it wasn’t for that particular someone that pay me (or was it a donation?) to update this theme, it probably took ages for me to do so.
It feels really great once you start to see the result. This probably too late to mention, but WordPress 2.7 is awesome. Sticky post, comment threading and paging, reply to comments, new template tags has been added to this theme. Hoping to repackage it soon for public consumption.
Relying on external content can be no fun at all. Especially dealing with broken link, deleted media etc. If it’s mine or belong to me, that wouldn’t be a problem. YouTube videos, flickr photos — now who doesn’t link or embed to that.
So I guess that’s why we see a lot of duplicate video in YouTube. Probably just in case.
Dump this code anywhere in Theme’s template functions.php file (For example, functions.php file for a Theme named “default” would probably reside in the directory wp-content/themes/default/functions.php):
add_filter('gallery_style',
create_function(
'$css',
'return preg_replace("#<style type=\'text/css\'>(.*?)</style>#s", "", $css);'
)
);
And these are the classes for your stylesheet:
.gallery {}
.gallery-item {}
.gallery-icon {}
.gallery-caption {}