Blog

  • Improving WordPress Search

    Improving WordPress Search

    WordPress search sucks. It’s well known.

    A friend has been looking for what he thinks is the solution and, let’s be honest, he’s got it pretty much right.

    He believes any half-decent search should…

    1. return posts by most relevant first
    2. do proper searches based on the phrase you submit
    3. indicate which words matched the post
    4. show how many posts matched
    5. list the posts by just title, or summary or full and allow you to switch
    6. show which page you’re on, if there are more than one page of results

    I’m not sure about point 5 – your average search engine, for instance, will give a summary and title and allow you to click it for the full details. I think a search should work like that.

    Unfortunately my friend hasn’t found a solution..

    I’ve looked at various plugins, but not really had any luck finding one which fixes all the problems.

    So, not knowing whether I would be able to solve this dilemma with existing plugins or if I’d end up writing my own, I set about finding an answer.

    And I did.

    Here’s what you need to do.

    Improving the Search Results

    Install Search Unleashed. This will add an improved search ability, will show post summaries, highlight searched text and display results in order of relevance.

    I also found I had to manually update my themes search.php file to change the rest of the summarised output – removing the calendar image, etc. You don’t have to do this, but it provided a nice compact result.

    Show the Number of Results

    Install Results Count. You will then need to add some code not only to your search.php theme file but (if you want) to archive.php. This will now display the number of results and which ones you are current viewing. For example, Showing results  1 - 16 of 32 for the search term:  wordpress.

    Install WP Page Numbers. Again, you will need to follow the instructions for inserting the appropriate code into search.php. The configuration options will also allow you to change the style of the output. What this plugin does, in a nutshell, is display the current page of results plus lists the other pages available, and let’s you move between them. For example…

    Line Numbers Example

    Increasing the number of Search Results Per Page

    The one problem with summarising your search results is that the blogs are a lot smaller on the page. WordPress only gives you one place to specify the number of posts per page and this applies to all forms of output – this means that the summarised results will take up a lot less of the page and, if there’s a lot of results, you may be aching to increase this number.

    In the case of my blog, I have the number of posts set to 5. I found that the number of summarised search results would look best at 16.

    Unfortunately, this is a bit of a manual fix. First of all, dig out your themes search.php file again. Hopefully you should be able to find the following line of code within it…

    <?php if (have_posts()) : ?>

    When you have, insert the following just before it…

    <?php
    $wp_query->query_vars["posts_per_page"] = 16;
    $wp_query->get_posts();
    ?>

    This will override the number of posts just for the search results. This solution doesn’t work for the Results Count plugin though, so you will need to change this too. As it’s a change to the plugin code, be aware that you may need to make this change again if you ever update the plugin.

    In results-count.php, find the line…

    $numposts = $wp_query->found_posts;

    Now, insert after it…

    $posts_per_page=16;

    The Result

    I think that covers pretty much all of what Tony was after. Except point 5.

    If you’d like to try the results out then, well, do a search on this site. Feedback is always appreciated!

  • Slippy slippy slip sliding

    The view from my office window
    The view from my office window
    An apt description of my drive to work. Thankfully it was early and traffic was light. I took my time and drove carefully. The snow outside is a lot, lot worse than at the beginning of the week and it’s continuing to come down.

    Unfortunately, it was all let down by selfish drivers. On icy roads the last thing you want is for other drivers to not indicate properly, causing you to have to brake unnecessarily. Or to tail-gate you.

    You’d also expect other drivers to take the weather into account with regard to how they react to other drivers on the road. So, when I was coming down a hill about to take a tight turn onto a junction, you’d expect other drivers to expect that manoeuvre to potentially go a bit, erm, wrong. Which it did. My back end slid out and I did a nice wide arc towards the junction. So why in the name of blither did the person coming up that road towards the junction not hold back? Why did he drive right up to the junction, right in my way? Thankfully I gained control and missed him. But even my mid-slide gesture for him to get out of the way was met with blank looks. Unbelievable.

    Anyway, at work in one piece. The snow has now stopped and it’s beginning to thaw already. Apparently warm rain is due.

    And during all of this, the Vodafone and Orange mobile networks have been flaky (probably due to the number of texts and phone calls). O2 appeared fine, however.

  • Choosing a Netbook

    So, yes, I’m still in the market for a Netbook but I’ve changed my mind about have an SSD. Now, call me fussy but here is what I’m after…

    1. Windows XP
    2. An Atom processor
    3. At least 16 GB hard drive
    4. 1 GB memory
    5. A resolution of, at least, 1024×600
    6. Small, but with a good keyboard
    7. As close to £200 as possible. £280+ is out of my range
    8. A good case for it – if it doesn’t come with a good one, I need to be able to get one
    9. If it doesn’t have a good battery life I want the option, in future, to buy a larger battery

    Surely that’s not too hard? My wife has an early Asus EEE PC but I don’t get on with the keyboard.

    The Dell is now out of the running due to the cost, but I’m left with the Acer Aspire One and the Advent.

    The Advent 4490, at £230, looked perfect. All the specs were there. BUT. It has average battery life and other than a £70 monstrosity, I can’t find a replacement battery for it.

    Having said, I read that it was the same as the MSI Wind, which does have spares but after some careful comparison I realised that the 4990 is NOT an MSI Wind. And Advents support is poor.

    The more I look into these Netbooks, the more confused I got. They’re all pretty much the same kind of spec, but they all have their pros and cons.

    Now I’m looking at the Acer Aspire One – it doesn’t have the best battery, but at least there are larger capacity ones available.

    Hmmm. Stay tuned – I’m sure I’ll make a decision one day!

  • Dell Customer Service

    Or rather my most recent online chat with them about the Dell Mini 9. Here is, word-for-word (but with personal details removed), how it went (my lines in bold)…

    Initial Question/Comment: Are there any further offers on the XP Mini 9?

    Thank you for contacting Dell Sales Chat. This is xxxxxx xxxxxx, your Sales Advisor. Please give me a moment while I review your query. In order to serve you better, may I have your telephone number & email address, just in case of disconnection I can either call you or email you back. My email address xxxxxx_xxxxxx@dell.com and Dell dial number 0870 9075 128 Ext: xxxxx

    My number is xxxx xxxxxxx, my email xxxxxx

    Thanks for the contact details

    Well David Dell don’t offer any further discount on the products.

    Oh. Ok. The price has gone up recently, and it’s now outside of my budget range

    All right

    Is that it? No attempt to get a sale from me? No offers?

    David i am not suppose to offer any further deals on the system.

    Who can then? Surely you don’t wish me to now go and spend my money elsewhere?

    Dell don’t have the discounting policy any more.

    Do you know why the Mini 9 has shot up in price? A week ago it had a £20 off and was £279. That makes the “full price” £299. However, you’re now selling it for £329, with £10 off. That makes the full price £339 now. With the Mini 10 coming out, I thought you’d be dropping the price, not increasing it.

    Just to let you know we start new promotions on every Thursday morning and the present promotion will be expired.

    Will it be replaced with another?

    I cannot inform you about it as of now as there is no information available.

    Ok. Thanks. You’ve been helpful yet no help at all!! I’ll take my money somewhere else.

    Thank you for contacting Dell Sales Chat and allowing me the opportunity to assist you. Have a wonderful Day.

    And then it came up with a questionnaire for me to fill in. I enjoyed that.

    So, what we’ve learnt. Dell have stopped their discounting policy, so there is no haggling – the price on the site is what it is, even if as a customer you’d rather go elsewhere.

    But that’s the last such chat. I’ve given up with Dell (I became a recent fan because my work laptop, a Dell, is so good. However, even my employer is now going elsewhere).

  • Dell Mini 9

    Even after my recent problems trying to get a decent price out of Dell for one of these, I’m still interested in getting a Mini 9.

    Their £20 off offer has official ended so I was keen to see how they’re selling now.

    I read earlier today about the imminent release of the Mini 10, so I’m thinking that Dell is likely to be wanting to shift their stock of Mini 9’s and this was maybe my chance. Why go for a Mini 9 when the superior Mini 10 will be out? Simple – the Mini 9 has an SSD drive. I can’t see the point in buying a small, robust, netbook that you can throw in a bag, etc, and stick a fragile HD in it. So, a Mini 9 it is.

    And the current selling price for the XP version… £329 with a £10 off offer. Excuse me? It was £279 last week with £20 off. That, in my estimate, made the full price £299. Now it’s £339? What gives? Who the hell is going to buy it now – that’s more than the far, far superior Samsung NC10 is selling for.

    Madness. Total madness.