Search Engine Query in Wordpress (Related Contents)

The widget aim is trying to reduce the bounce rate of your blog and provide the visitor a better navigation experience.

When a visitor lands on your site from a search engine result page, he is in need of a certain information / service your page might satisfy. It often happens the visitor go away just after reading that page, for various reasons. Why not to try suggesting him more posts on the topic he is interested in at that moment, so that he might visit more pages?

The Search Engine Query in Wordpress widget grabs the query the visitor used on the search engine, executes it in the blog search and displays results, suggesting the visitor more information about what he is actually looking for.

If the visitor does not come from a search engine and the current page is the single post template, the widget can display the most recent posts in the current post category. There is an option in the widget control panel to turn this feature down. In that case, if the user does not come from the search engine the widget box simply doesn’t appear.

Widget Features

  • If the visitor comes from a search engine result page, the widget grabs the search engine query, executes it in the internal search (with the WP_Query object) and shows results
  • If the visitor is browsing a post detail (is_single()) and the visit source was not a search engine result page, the widget get the current post category and shows the most recent posts in that category
  • If the “Track clicks” option is enabled in the widget control panel, the plugin adds campaign dimension tags to links in the widget box.
    If your web analytics tool supports them, you’ll find a “Search engine query in WP widget” campaign that will allow you to understand how many clicks where produced by the widget box and if they were made from the category search or the search engine query search
  • The widget contrtrol panel lets you choose:
    1. The widget box title
    2. The number of related posts to display
    3. To search by category if the search engine query is not available
    4. To track clicks with campaign link tags
  • The widget layout can be customized by editing the seq_in_wp.css css file located in the plugin directory

Installation

  1. Unzip and upload ’search-engine-query-in-wp’ directory to your ‘/wp-content/plugins/’ directory
  2. Activate the plugin through the ‘Plugins’ menu in the admin panel
  3. Activete the widget in the ‘Appearance -> Widgets’ section of the Admin panel
  4. Edit widget settings in the ‘Appearance -> Widgets -> Search Engine Query in WP’ for fine tuning (Title, number of posts, ajax, email etc.)
  5. Edit the seq_in_wp.css to change the box layout so that it fits your blog theme (not mandatory)

Changelog

  • 1.2.4: if jQuery is not loaded by default, the plugin enqueues the script in the <head> section (fixes the “emply box” bug)
  • 1.2.3: Far lighter Ajax scripts, integrated with Wordpress Jquery, the plugin auto-check requirements upon installation and deactivate itself it something is missing
  • 1.2.2: “Install” bug and “wp-config.php not found” bug fixed. Php 5.0 or higher is required anyway. Will work on backwards compatibility soon indeed
  • 1.2: option for executing the search on Ajax technology after the page has loaded, WP Super Cache compatibility, translations, logs by email, cool fade out effect if there are no related posts and much more ;)
  • 1.1.1: more search engines supported, safer coding
  • 1.0.7: first public release

Enhancements / todo list

  • Support more search engines (suggest your favourite and I’ll add it)
  • Better coding (Class instead of functions, some comments are in Italian)
  • Option for showing random posts if related are not found

Download Search Engine Query in Wordpress widget now! It’s free :P

Some sites using it

If this plugin is worth for you, if it actually reduced your bounce rate, consider donating a very few bucks for the time I spent developing it ;)

  1. January 29th, 2009 at 00:49 | #1

    hi. Thanks for plugin

    perfect.

    Regards

  2. January 29th, 2009 at 03:23 | #2

    There are several, well established, related posts plugins out there. I would suggest your plugin feeds them, if installed, with the search query rather than trying to find yet another set of related posts. This approach will make your plugin much simpler as all it has to do is 1) capture the search term 2) determine if this is a page/post or the index and 3) pass the search term to the related posts plugin.

    Also, how is the plugin’s function affected by WP Super Cache or similar plugins?

  3. January 29th, 2009 at 11:23 | #3

    @Your Life Regained
    Thanks Your Life :)
    If the visitor comes from a search engine, related posts are fetched by the internal wordpress search methods.
    I thought about interacting with an existing “related posts” plugin if the visitor is not coming from a search engine search but… I haven’t found any in the official plugin directory :P Could you suggest one?

    Finally I am not going to support WP Cache or WP Super Cache because I am going to write my own caching system. I don’t like those plugins because if the user is not logged or has not commented yet, they do not show dynamic parts of the page (comments!!).
    What I’d like my a caching system to do is staticize just the post, not comments so that it reduces the number of queries executed, but still executes some. I’ve already done that for many cms, I need some time to study wordpress core to port that system here ;)

  4. January 29th, 2009 at 16:17 | #4

    There are several related posts plugins that have gained popularity:

    http://wordpress.org/extend/plugins/similar-posts/
    http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/

    as well as a plugin that does landing page optimization, similar to what you do:

    http://wordpress.org/extend/plugins/landing-sites/

    As far as not supporting WP Super Cache, my recommendation is to consider a middle ground, where you develop you own plugin for the cache system instead of outright ignoring it. The reality is that the WPC plugin has a significant installed based and not supporting it is going to limit the adoption of your own plugin.

    @devu

  5. February 3rd, 2009 at 00:17 | #5

    Hey there! Great plugin!

    Can I use it in my templates? Is there a way to call the function using PHP and not the widget?

    Many thanks!

  6. February 3rd, 2009 at 09:48 | #6

    @Psyk
    Thanks :)
    Yes, just copy this snippet in your theme:

    < ?php if (function_exists('SEQ_in_wp')) SEQ_in_wp(array()); ?>

    If you don’t have widget configuration too, just tune widget settings in the SEQ_getDefaults function:

    $options['title'] = ‘Related Posts’;
    $options['show_category'] = ‘true’;
    $options['track_clicks'] = ‘true’;
    $options['number'] = 5;
    $options['use_ajax'] = false;

  7. February 3rd, 2009 at 23:35 | #7

    I’m looking for someone with the WP Super Cache plugin to test the new ajax version of this widget ;)
    Anyone?

  8. February 4th, 2009 at 17:43 | #8

    Nice plugin.
    If you plan to support multiple languages, drop me a line I’ll translate it in italian.

  9. February 6th, 2009 at 01:05 | #9

    @blau
    Translations are now available :) I did my best with it_IT but if you’d like to contribute… you’re more than welcome ^__^

  10. February 6th, 2009 at 06:02 | #10

    Hi,

    AWESOME plug-in. Instantly one of my “must-have” plug-ins. But… Everything worked perfectly until I installed V1.2. WP barfed all over it. Can I get the rev 1.1.1 again? The auto-upgrade function in WP nuked the previous version.

    Thanks a million. Great stuff!

    CG

  11. February 6th, 2009 at 08:33 | #11

    @Chuck Gillooley
    Hi Chuck,
    sorry for that. The 1.1.1 version is always available @wordpress.org: http://wordpress.org/extend/plugins/search-engine-query-in-wordpress-related-contents/download/

    Before rolling back I suggest you to try manually install the 1.2 version. I’ve never tested auto-update with this plugin, I’d better do it :P

    Could you report here what WP didn’t like about the new version?

  12. February 7th, 2009 at 19:11 | #12

    I get this error inside the widget box:

    Warning: require_once(wp-config.php) [function.require-once]: failed to open stream: No such file or directory in /nfs/c01/h02/mnt/34828/domains/phoenixrealestateguy.com/html/wp-content/plugins/search-engine-query-in-wordpress-related-contents/external.php on line 44

    Fatal error: require_once() [function.require]: Failed opening required ‘wp-config.php’ (include_path=’.:/usr/local/php-5.2.6-1/share/pear’) in /nfs/c01/h02/mnt/34828/domains/phoenixrealestateguy.com/html/wp-content/plugins/search-engine-query-in-wordpress-related-contents/external.php on line 44

  13. February 8th, 2009 at 00:30 | #13

    @Jay Thompson
    Thanks Jay. For a very fast fix replace in external.php line 44:

    require_once($inc_path.”wp-config.php”);

    with

    require_once(“../../../wp-config.php”);

    Let me know if it works.

  14. lorenzo
    February 8th, 2009 at 13:01 | #14

    hi Francesco
    thanks for your work,this plug is great, unfortunately in a blog
    i’ve got : Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/userxxx/domains/userxxx.org/public_html/wp-content/plugins/search-engine-query-in-wordpress-related-contents/lib.php on line 10

    the
    private $seqOptions;
    what shall I do?

  15. February 8th, 2009 at 13:08 | #15

    @lorenzo
    Hi Lorenzo,
    unfortunately your server does not support php5 :(
    You could:
    - delete all “private ” and “public ” instructions you find in the lib.php file
    - go back to the 1.1.1 version which support php4: http://wordpress.org/extend/plugins/search-engine-query-in-wordpress-related-contents/download/

  16. lorenzo
    February 8th, 2009 at 16:03 | #16

    @devu

    Many many thanks for this prompt and precise reply Francesco,
    so I’m not alone ‘celebrating’ the day of the Sun, indeed (LOL)
    plugin (1.1.1) installed and running, monday it’ll be CSSed .
    ciao e graxie

  17. February 8th, 2009 at 16:10 | #17

    @devu
    Works like a charm. Thanks!

  18. February 8th, 2009 at 16:11 | #18

    @devu
    Works like a charm, thanks! Great plug in!

  19. February 9th, 2009 at 20:12 | #19

    @devu

    PHP 5 turned out to be the culprit. I was getting the same error message as Lorenzo did, but when I upgraded to PHP 5, everything worked perfectly. What a great plug-in!!

  20. February 10th, 2009 at 09:15 | #20

    @Chuck Gillooley
    Looks very cool on your blog! Have you tried the “Email log feature”? What do you think?

    @Jay Thompson
    Jay, the “Loading” icon seems too big for your blog layout. Can I suggest you to replace it with a smaller one? Look at here :)

  21. February 17th, 2009 at 04:34 | #21

    Will this create duplicates on the single page if I use this along with related Posts using YARP PLugin.

  22. affiliate.solutions
    February 17th, 2009 at 06:41 | #22

    Very nice information. Check out my blog, I just posted a great blog about the 36 Best Wordpress plugins for 2009.

  23. February 17th, 2009 at 09:23 | #23

    @Avinash Just disable the Show category posts if no results with “search engine query” are found option and the box will appear only when visitors come from search engines.

  24. Hayden
    February 21st, 2009 at 17:52 | #24

    How about integrating the functions of WP-Greetbox and Referer Detector into this plugin.
    And it would be a perfect referer plugin concerned about not only traffic from search engine but from social networks.

  25. April 12th, 2009 at 01:16 | #25

    @devu
    I’ve got an empty box.
    I’m using wp-super-cache… Can I help you?

  26. April 12th, 2009 at 19:45 | #26

    @Pande
    I’m using WP Super Cache too, and the plugin is working as you can see on the right column. Do you have the last “Search Engine Query in Wordpress” version? Be sure the “Use Ajax technology” checkbox in the plugin settings is checked, so that the database query is run from javascript after the static page is loaded.

  27. April 22nd, 2009 at 22:46 | #27

    I am the same issue as Pande. I have an empty box and I am using super-cache, wordpress 2.7.1, and I am using the last plugin version and using ajax technology in the plugin settings.

    Maybe the plugin is not working with the 2.7.1 version?

  28. May 11th, 2009 at 08:49 | #28

    Hi

    Its not working for me. It displays posts from one category always and I disabled it from the widget. Now, it says no related posts every time and dissapears!

  29. Matteo
    May 25th, 2009 at 22:33 | #29

    Ciao Francesco,

    posso parlare italiano ?

    Ho provato ad installare il tuo plugin ma sembra non funzionare…
    Si attiva correttamente ma quando inserisco il widget, rimane soltanto il titolo senza visualizzare niente.

    Il sito gira su Wp 2.7.1 con php5.

    Consigli ?

    Grazie mille.

  30. May 26th, 2009 at 11:33 | #30

    I’m sorry for the delay, it’s that I have been very very busy with a few projects and couldn’t find the time to check the plugin and debug the problem.

    Here we are: I read the wordpress documentation and understood that since WP 2.5.something jquery was included in every blog and took it as an assumption. Now jquery is loaded by themes and if themes do not apply developer guidelines (don’t load jquery), you’ll see the box empty and not working.

    Here is the fast workaround you can use, until I update the official release with subversion.

    1) Open your /wp-content/plugins/search-engine-query-in-wp/search-engine-query-in-wp.php file with a text editor
    2) Add a new line after line 113 (line 113 should contain echo ‘<link rel=”stylesheet” href=”‘.$seqiwp_base_url.’/seq_in_wp.css” type=”text/css” />’;)
    3) At line 114, paste this: wp_enqueue_script(‘jquery’);
    4) Save and upload

  31. June 16th, 2009 at 02:28 | #31

    Is the manual snippet you posted here going to render any html if the visitor doesn’t come from a search engine?

  32. June 17th, 2009 at 01:26 | #32

    Will this work if I put it in the 404 template?
    I’m asking because it is already a redirected page, and I wonder if the query will be still there at that stage.

  33. Jesse
    July 7th, 2009 at 14:45 | #33

    Hi,
    I tried to install the plugin on version 2.8 wp and got this error:
    Unpacking the package.

    Incompatible archive PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature

  34. July 10th, 2009 at 09:51 | #34

    @Jesse
    It’s odd because the zip archive is created by wordpress.org. With svn I just upload the plugin files.
    Hmmm

  35. July 10th, 2009 at 09:57 | #35

    @sergio
    Depends on how the redirect is done: the plugin uses the $_SERVER["HTTP_REFERER"] variable.

  36. August 13th, 2009 at 10:54 | #36

    Fixed adding the line!
    Great…

  37. August 24th, 2009 at 20:04 | #37

    Thank you for information

    i’ll test it in my site and if no problem with theme and search unleashed i’ll put it cuz it is very important for new users

  38. October 4th, 2009 at 04:16 | #38

    cool plugin but all the time it showing no related post found :(

  39. November 18th, 2009 at 11:47 | #39

    Hey this is great plugin!

    Thanks so much…it really is cool addition. I’ve put it to show at beginning of posts and then have YARRP at the end of posts.

    This was interesting because your plug showed results and YARPP showed nothing related (maybe the setting are too high ;)

    Anyways, I think it’s great!

    Would you be able to have the *Category* that it suggests in the results become a link to that actual *Category*?

  40. November 30th, 2009 at 02:26 | #40

    This is a great plugin.. Infact I liked it so much that I removed YARPP

    Is it possible to add wordpress TAGS support for related post instead of category

  41. December 8th, 2009 at 01:16 | #41

    is there a way to display the search engine query and related posts outside of a the widget (ie, on a page or in a post)

  42. December 21st, 2009 at 16:50 | #42

    @devu

    hello. i like it and i want to translate it in greek.What sould i replace?

  43. December 21st, 2009 at 20:57 | #43

    i create the po files. but when i upload them, notning hapens. Should i create mo files also? & if yes how the end user load them? ( i cant load the fr translation for example)

  44. slash30
    January 4th, 2010 at 02:13 | #44

    Hey great plugin. I saw the comment with “” to add it to the theme but is there and easy way to show the actual keyword from the search engine query just by itself in a post or the theme?

    Thanks much.

  1. January 29th, 2009 at 17:56 | #1
  2. January 29th, 2009 at 18:52 | #2
  3. January 29th, 2009 at 20:42 | #3
  4. February 5th, 2009 at 08:40 | #4
  5. February 17th, 2009 at 08:34 | #5
  6. March 14th, 2009 at 17:50 | #6
  7. April 7th, 2009 at 13:36 | #7
  8. August 3rd, 2009 at 15:30 | #8