Jerome's Keywords - Local Search Results

Updated 13-Jan-2007 15:48

You can search for all posts matching a particular keyword on your site by opening the URL index.php?tag=keyword — this is by default what your displayed keywords link to.

Setting up a local search results page is easy and should work right out of the box for most users. Here’s what you need to look into if you want to customize the results page or if this feature isn’t working for you.

  1. Templates By default, the plugin looks for a file named keywords.php in your active template’s directory. If it can’t find this file, it will try (in order) tags.php, category.php or index.php. This template file controls what the keyword search results will look like. To create your own results template, create keywords.php (or tags.php) by copying one of your existing templates. I would suggest using search.php or category.php as a starting point. You can then customize the layout and text of this template file. To display the name of the keyword being searched you can use <?php the_search_keytag() ?> Note: the function get_the_search_keytag() is a non-echoing version.
  2. Rewrite Rules If you are using mod_rewrite for your permalinks, the plugin will automatically add the necessary rules to your .htaccess file whenever you update your permalink settings. Make sure that you re-save your permalink settings in Options-Permalinks after installing this plugin. If WordPress cannot write to your .htaccess file, you will need to add the following lines by hand (ignore this if you don’t use permalinks):
    
    RewriteRule ^tag/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$ /index.php?tag=$1&feed=$2 [QSA,L]
    RewriteRule ^tag/(.+)/(feed|rdf|rss|rss2|atom)/?$ /index.php?tag=$1&feed=$2 [QSA,L]
    RewriteRule ^tag/(.+)/page/?([0-9]{1,})/?$ /index.php?tag=$1&paged=$2 [QSA,L]
    RewriteRule ^tag/(.+)/?$ /index.php?tag=$1 [QSA,L]
    

I’ve created a keywords search results template file that you can use with the Kubrick (default) theme.