Blog

  • Improving WordPress Search Further

    I wrote an article some time ago highlighting ways to implement search improvements to WordPress (and the default search DOES suck). Now, I’d like to update you on where I am, including some further changes that I made last night.

    Current Set-up

    My current set-up is that I’m displaying 3 posts per page. However, in the case of search results, I’m displaying 12 per page, as I display only an excerpt and restricted social sharing and other output. The idea, like the results from a search engine, is to find the post or page that you’re after and click on it for the full version.

    Recommended Plugins

    By default,WordPress only allows one “posts per page” value. To achieve this, you’ll need to read my original post which shows you how to override the search results to show more. I still use the Results Count plugin as well, which displays how many search results were returned.

    In addition, on all post and page types I use the WP Page Numbers plugin to allow users to easily scroll across multiple pages, rather than use the default WordPress “Next” and “Prev” buttons.

    Finally, Search Meter is an excellent plugin for finding out what your visitors are searching for.

    Modifying the Search Results

    Last night I had a brain-wave. After performing a search myself, I had one result. Except it was the usual excerpt and I had to click on it to view the full version. But, if there’s only one, why do this? Indeed, if there’s 3 or less, why not display the full posts, and only collapse to the excerpt version if there’s more than this?

    And that’s what I’ve changed – try it! Look for “wordpress“, for instance, and you’ll find pages of potential results, all displayed as limited excerpts. Look for “avforum” and one result will be returned and the entire post will be shown. Lovely.

    To do this I simply compare the results of $wp_query->found_posts with get_option('posts_per_page'). I do this outside of “the loop”.  The former will return the total number of posts being returned and the latter will return the number of posts per page that you’ve your WordPress to. In my case, this latter value is 3.

    So, if a search is performed and 1 results is returned out of 3, my theme can make the decision to output the full version of the post instead of the smaller version. I can also make the decision at this point whether to override the number per page to 12 or not (if I’m display the excertp versions).

    I hope this makes sense – please comment if you need any further clarity on this.

  • Amazon Kindle eBook Reader

    For a while I’ve been watching the eBook reader market with interest. Not necessarily for myself, but my wife is an avid book reader, and only a truly amazing device would probably move her away from the paper variety.

    Amazon’s Kindle was a start, but it relied on a limited 3G network arrangement in the UK (basically it was a US company providing it, so to keep costs down images, for instance, for newspapers were suppressed). However, it’s ability to easily download newspapers and magazines directly to the device was a real selling point.

    On July 29th, Amazon.co.uk started taking pre-orders for the all-new Kindle featuring a new electronic-ink screen with 50 percent better contrast than any other e-reader, a new sleek design with 21 percent smaller body than the previous Kindle, while still keeping the same 6-inch-size reading area, and a 15 percent lighter weight. The all-new Kindle with wi-fi is available for £109 and with free 3G wireless and wi-fi for £149. Both of these prices are, I have to say, are amazingly good.

    The UK Kindle Store features a vast selection of titles – including new releases and bestsellers. In addition, over 170 top UK and international newspapers and magazines are also available in the UK Kindle store for single purchase or subscription. All subscriptions are auto-delivered wirelessly to Kindle and start with a free 14-day trial.

    The full of improvements in the new Kindle are…

    • All-New, High-Contrast E-Ink Screen – 50% better contrast than any other e-reader
    • Read in Bright Sunlight – No glare
    • New and Improved Fonts – New crisper, darker fonts
    • New Sleek Design – 21% smaller body while keeping the same 6″ size reading area
    • 15% Lighter – Only 247 grams, weighs less than a paperback
    • Battery Life of One Month – A single charge lasts up to one month with wireless off
    • Double the Storage – Up to 3,500 books
    • Books in 60 seconds – Download books anytime, anywhere
    • Free 3G Wireless – No monthly payments, no annual contracts
    • Built-In Wi-Fi – In addition to the 3G wireless, you can connect to Wi-Fi hotspots
    • 20% Faster Page Turns – Seamless reading
    • Enhanced PDF Reader – With dictionary lookup, notes, and highlights
    • New WebKit-Based Browser – Free 3G web browsing (experimental)

    If you’ve been interested in an eBook reader and haven’t yet “taken the plunge” then I think this is an excellent time to finally give it a try.

  • Mole, R.I.P.

    Back in, oooo, the mid 1990’s, I set up about writing a new system at work. Named “Mole” it was designed to be a knowledge-base system with extensive search capabilities. It was written on the company mainframe, using an online language called RPF (Roscoe Programming Facility). At the time, we hadn’t long had PCs, so the mainframe was still where most development occurred.

    It was text only but I wrote intelligent search capabilities matching and, I think exceeding, those provided by the internet search engines at the time. I launched different versions, with names echoing those of Microsoft at the time. For example, Mole RX (which stood for “reduced indexing” – the number of index files was greatly reduced giving a greater search performance). The final version had a Beta search facility that really was (even if I do say so) exceptionally good.

    Indeed, Mole was a big hit. The support teams loved it and I even one an internal IT award for “Innovation”, beating a lot of other high-profile entrants.

    Sadly, the manager of the IT Help Desk (who was likely to be the biggest user) didn’t like it. The mainframe wasn’t the way forward – PC applications, particularly one built into their call logging systems was the way.

    Now it’s 2010 and the same Help Desk still lack a half decent knowledge-base – nothing was ever delivered other than the most basic facilities.

    A few months ago, I archived the Mole code away into a dataset. Sadly, unbeknown to myself, the dataset has been “housekept”. All that was left of Mole has gone. The manual I can no longer find. Not even the Mole logo.

    I’m quite sad about it really – it was something I put a lot of time into and I was very proud of.

  • The WordPress Loop

    I often get asked about “the loop” in WordPress, as many of my plugins require knowledge of it for successful integration.

    “The loop” is simply some WordPress code that handles the fetching of post or pages. Each WordPress theme has a number of files that handle different types of output – for instance, index.php is used for displaying a number of posts, page.php displays pages and single.php shows a single post. Each of these contains the code for the loop.

    The first line is usually this…

    <?php while (have_posts()) : the_post(); ?>

    And the last line is usually…

    <?php endwhile; ?>

    Everything in between is the setting up and displaying of the post/page in question.

    So, let’s use Simple Social Bookmarks as an example. You will probably want to put the function call for this just before that last line of the loop – that will it will be the last thing displayed after each post or page. However, you may want other content to appear first, in which case you will choose a different location between the above 2 lines to put it.

    What I can’t tell you is exactly where you need to put the code – that’s entirely down to you and how you wish the output. Indeed, there’s no reason why, in the case of Simple Social Bookmarks, you have to put it in the loop – you could have one at the top of each page. Bear in mind, however, that if you put code outside of the loop then it may not be able to get certain information – in out example, you’d have to supply a URL, as normally this is supplied by the loop to indicate the current post/page.

    I hope this makes sense. If not, you can read more about it at WordPress.org.

  • Lucie’s early steps

    I took this video a little earlier. It’s only the second day she’s been walking to this extent (she’d taken the odd 2/3 steps over previous weeks). I’m a very proud Daddy.