Some Good WordPress Hacks

Impact sent us a link to this article about some useful WordPress hacks:

The ninth entry, “Highlight Searched Text In Search Results” is a tiny code snippet god-send if you are regular expression illiterate like us:

$content = nl2br ( strip_tags ( get_the_content ( __( 'more…' ) ) ) );
$keys = explode ( " ", $s );
$content = preg_replace ( "/(" . implode ( "|", $keys ) . ")/iu",

'<strong class="search-excerpt">\0</strong>',


Works like a champ!

There is also another helpful trick in this article. Up at number four, “Create A Maintenance Page For Your WordPress Blog”. This one is an .htaccess modification to keep visitors from seeing your site while you are making updates…

RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$
RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123
RewriteRule $ /maintenance.html [R=302,L]

Replace the IP Address with yours and you’ll be able to see your pages but everyone else will get redirected to the maintenance.html page. Brilliant!