Haystack

Description

Modern, mobile-friendly web design simplifies navigation but makes it harder to locate specific content. By adding Haystack to your site, your search bar becomes a super-charged, auto-completing web utility that helps people quickly find what they’re looking for.

Screenshots

  • Go to https://haystack.menu/ to get your license for the Haystack search

FAQ

How do I obtain a license for Haystack?

Got to Haystack.menu and follow the simple steps in order to create your account and receive access.

Are there ways to override the content sent up to the server? Such as images or content so that I can make my searches more customizable?

Haystack has built in filters that allow you to change some defined variables that represent your web page. Currently the filters haystack_set_type, haystack_set_image, haystack_set_body, and haystack_set_tags have been enabled. These functions are passed the ID of the post, and the returned data will be sent to elasticsearch.

Here are two examples set in a user’s theme folder in their functions.php file:

//We want type here to show much more data than the average
function _haystack_set_type($id) {
  //Adding post type as the first of the tags to pass
  $post_type = get_post_type($id);
  $post_type = get_post_type_object($post_type);
  $tags[] = array($post_type->labels->singular_name);

  //Adding the post author as the second part of the tags array to pass
  $post_auth = get_post($id);
  $post_auth = $post_auth->post_author;
  $tags[] = get_the_author_meta('nicename',$post_auth);

  //Adding categories to the array
  $post_cat = wp_get_post_categories($id);
  foreach ($post_cat as $c) {
    $cat = get_category($c);
    $tags[] = $cat->name;
  }

  //Adding tags associated with the post, if they exist
  $post_tags = wp_get_post_tags($id);
  foreach ($post_tags as $key => $val) {
    $tags[] = $val->name;
  }

  //Return in <cat> tags
  return (!empty($tags) ? '<cat>'.implode('</cat><cat>',$tags).'</cat>' : '');
}
//Apply the filter
add_filter('haystack_set_type','_haystack_set_type');

The second example here hooks in and replaces all images with a static one:

//Add a sample image to each Haystack post item. Image could alternately be fetched from the ID
function _haystack_set_image($id) {
  return 'http://www.gallaghersmash.com/wp-content/uploads/2015/04/gallagher.jpg';
}
//Apply the filter
add_filter('haystack_set_image','_haystack_set_image');

Changelog

1.0

  • The first version of the plugin has been created.

Contributors & Developers

This is open source software. The following people have contributed to this plugin.

Contributors

Browse the code