WordPress Page 2
# 
Photo credit added automatically to every photo with a caption (via putukrejums.lv)
Crediting and linking the source of any republished photo or illustration on the web is one of the most important best practices of web publishing. Unfortunately, there isn’t a standard way of doing it in WordPress and authors are left with their own decision on how and where to credit the original author or website. Read more »
# add_filter('get_previous_post_where', 'remove_stickies_adjacent');
add_filter('get_next_post_where', 'remove_stickies_adjacent');
function remove_stickies_adjacent($where) {
return $where . ' AND p.ID NOT IN (' . implode(',', get_option('sticky_posts')) . ')';
}
# 
Here is the second iteration of the UX update for the Widget Context plugin. Please check out the live demo and let me know what you think! Read more »
# Update: there is a new version of the UX update available.

For the next release of the Widget Context plugin I have two goals — simplified user interface and code clean-up to eliminate PHP notices. Read more »
# 
Page Speed score of my blog: 97/100
WordPress can be very fast. Here is the server-side setup for achieving the 97/100 Page Speed score (it is only because of Google Analytics that the score is not 100/100): Read more »
# I have just released an update (version 0.4.1) to the Multiple Galleries plugin, which should fix all the compatibility issues with WordPress 3.1.x and the upcoming 3.2. An update should appear in your WordPress dashboard soon.
# Inline CSS and line breaks <br style="clear" /> that are automatically added to the image galleries in WordPress is an example of how the needs of Automattic and WordPress.com influence the way new features are added to the WordPress core. So instead of editing every single theme on WordPress.com and adding the necessary CSS for galleries to look good in all of them, they decided to put it WordPress core.
Here is how to replace those double line breaks with a single <br /> and remove the inline CSS:
add_filter('the_content', 'remove_br_gallery', 11);
function remove_br_gallery($output) {
return preg_replace('/(<br[^>]*>\s*){2,}/', '<br />', $output);
}
add_filter('use_default_gallery_style', '__return_false');
# If you want to use either Fancybox or Lightbox scripts for image galleries, you need to add the rel attribute to all full size image links. Here is how to do it:
add_filter('wp_get_attachment_link', 'add_gallery_id_rel');
function add_gallery_id_rel($link) {
global $post;
return str_replace('<a href', '<a rel="gallery-'. $post->ID .'" href', $link);
}
We simply replace <a href with <a rel="gallery-n" href where n is a unique post ID. This filter is applied in /wp-includes/post-template.php.
# WordPress doesn’t know that your Nginx web server is capable of doing URL rewrites without mod_rewrite and Apache, so we explain that by adding:
add_filter('got_rewrite', 'nginx_has_rewrites');
function nginx_has_rewrites() {
return true;
}
in your theme’s functions.php.
It is very likely that along Nginx you are also running PHP-FPM for all your PHP needs, and for some reason WordPress thinks its PHP process can’t write to disk. We tell WordPress that it can:
add_filter('filesystem_method', 'nginx_make_filesystem_direct');
function nginx_make_filesystem_direct() {
return 'direct';
}
# Built-in search engines of WordPress, Drupal and other content management systems are good, but not as good as Google. Here is a simple way to create a Google search form that will return results only from your site:
<form name="google-search" method="get" action="http://www.google.com/search">
<input type="hidden" name="sitesearch" value="http://yourdomain.com/" />
<input name="q" type="text" />
<input type="submit" name="sa" value="Google" />
</form>
which will look like this:
This form does redirect your visitors to Google, but the results returned are only from your site, so there is nothing to worry about. And with Googling indexing blogs almost instantly, there are actually very little drawbacks from using this approach for site search.