Nov 1, 2011
WordPress

add_filter('wp_list_categories', 'remove_category_link_prefix');
function remove_category_link_prefix($output) {
return str_replace('View all posts filed under ', '', $output);
}
#
Oct 16, 2011
WordPress

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 »
#
Sep 8, 2011
WordPress
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')) . ')';
}
#
Dec 26, 2009
WordPress
Update: Ryan has made this into a plugin — Code Comments.
Add this to your theme’s functions.php to allow readers post fragments of code in their comments (wrapped in <code>...</code>) which are automatically encoded (think of < and <)
add_filter('pre_comment_content', 'encode_code_in_comment');
function encode_code_in_comment($source) {
$encoded = preg_replace_callback('/<code>(.*?)<\/code>/ims',
create_function(
'$matches',
'$matches[1] = preg_replace(
array("/^[\r|\n]+/i", "/[\r|\n]+$/i"), "",
$matches[1]);
return "<code>" . htmlentities($matches[1]) . "</code>";'
),
$source);
if ($encoded)
return $encoded;
else
return $source;
}
Worth noting:
- Everything wrapped in
<code>...</code> is encoded.
- Line breaks after opening
<code> and before closing </code> are removed in order to avoid unnecessary <br /> tags.
#