Posts tagged how to Page 2

How to Add Simple Google Site Search to Any Website

#

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.

How to Add Shortlink Support to Twitter Tools

#

By default the Twitter Tools plugin uses URLs such as http://example.com/p=123 in your tweets. However, if you are using one of the URL shortener plugins (that make use of the standard get_shortlink() function), chances are that you would rather include the URL generated by that plugin. To do that, simply add this to your theme’s functions.php:

add_filter('tweet_blog_post_url', 'get_shortlink_for_twitter');
function get_shortlink_for_twitter($url) {
	return wp_get_shortlink(url_to_postid($url));
}

Standalone Script for Clearing APC Cache

#

After upgrading WordPress to a new version, you might need to clear the APC opcode cache. Here is a simple script that you can store in the root of your website, for example, clearapc.php:

if (function_exists('apc_clear_cache') && $_GET['pass'] == 'secret') {
        if (apc_clear_cache() && apc_clear_cache('user'))
                print 'All Clear!';
        else
                print 'Clearing Failed!';
        print '<pre>';
        print_r(apc_cache_info());
        print '</pre>';
} else {
        print 'Authenticate, please!';
}

Then call the script via http://example.com/clearapc.php?pass=secret

Instead of using ?pass=secret, you might well call the filename something that is hard to guess: clearapc93920.php

Show Ads Only to Visitors Coming from Search Engines

#

With the latest design update, I have stripped away most of the clutter in the form of secondary content. It also included removing most of the ads, just because 400 visitors a day is still to few to get more than a single click per day.

I decided to install Ozh’s Who Sees Ads plugin to make ads visible only to visitors coming from search engines. The problem, however, is that it shows ads only on the landing page and not on all pages that the user visits. Read more »