PHPackages                             sitecrafting/sitka-insights-wordpress - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. sitecrafting/sitka-insights-wordpress

ActiveWordpress-plugin[API Development](/categories/api)

sitecrafting/sitka-insights-wordpress
=====================================

Integrate your WordPress site with the Sitka Insights platform

v3.0.2(8mo ago)04.0k1[3 issues](https://github.com/sitecrafting/sitka-insights-wordpress/issues)[2 PRs](https://github.com/sitecrafting/sitka-insights-wordpress/pulls)MITPHPPHP &gt;=7.3CI failing

Since Dec 17Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/sitecrafting/sitka-insights-wordpress)[ Packagist](https://packagist.org/packages/sitecrafting/sitka-insights-wordpress)[ RSS](/packages/sitecrafting-sitka-insights-wordpress/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (3)Versions (50)Used By (0)

Sitka Insights for WordPress
============================

[](#sitka-insights-for-wordpress)

[![Travis CI build status](https://camo.githubusercontent.com/8de5ab49c74629229a3bb87464b2e650d3a4f5e9b863b2f4374720ab65874403/68747470733a2f2f6170692e7472617669732d63692e6f72672f736974656372616674696e672f7369746b612d696e7369676874732d776f726470726573732e7376673f6272616e63683d6d61696e)](https://camo.githubusercontent.com/8de5ab49c74629229a3bb87464b2e650d3a4f5e9b863b2f4374720ab65874403/68747470733a2f2f6170692e7472617669732d63692e6f72672f736974656372616674696e672f7369746b612d696e7369676874732d776f726470726573732e7376673f6272616e63683d6d61696e)

Integrate your WordPress site seamlessly with the Sitka Insights suite.

Installation
------------

[](#installation)

### Installing Manually

[](#installing-manually)

Go to the GitHub [releases page](https://github.com/sitecrafting/sitka-insights-wordpress/releases/) and download the .zip archive of the latest release. Make sure you download the release archive, **not** the source code archive. For example, if the latest release is called `v2.x.x`, click the download link that says **sitka-insights-v2.x.x.zip**. (You can also use the `tar.gz` archive if you want - they are the same code.)

Once downloaded and unzipped, place the extracted directory in `wp-content/plugins`. Activate the plugin from the WP Admin as you normally would.

### Installing via Composer

[](#installing-via-composer)

Add the requirement to your composer.json:

```
composer require sitecrafting/sitka-insights-wordpress --prefer-dist
```

*NOTE:* if you are tracking your WordPress codebase as one big monorepo, the `--prefer-dist` flag is important! It tells Composer to find and download the .zip archive instead of the full Git repository. Without this flag, it will create the plugin directory as a [Git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules) and strange things will happen.

Usage
-----

[](#usage)

### Getting Started

[](#getting-started)

After installing and activating the plugin, go to the *Sitka Insights* section of the WP Admin. Enter your *API Key*, *Collection ID*, and *Base URI* as provided by Sitka. All settings are required.

### Search

[](#search)

With Sitka Insights, you can override the default WordPress search functionality, which is extremely limited by default, with results from the ElasticSearch crawler that powers Sitka Search. To do this you must first enter your settings as described above, in **Getting Started**.

Once you've entered your Sitka Insights settings, but before enabling overriding WordPress search globally, you can test from the command line to see if you get results. To do this, run `wp sitka search `. You should see a JSON object like this:

```
{"results": [{"url": "https://www.example.com/example-page", "title": "Example Page", "snippet": "Some content"}, ...]}
```

Once you've entered the settings above correctly, you're ready to enable Sitka Insights Search to override the default WP search. Enable the option **Override default WordPress search** and save the settings again. You should now see a basic search results page rendered by Sitka Insights whenever you perform a search.

#### Search Shortcode

[](#search-shortcode)

Out of the box, you can use the `[sitka_search]` shortcode in any RTE that supports shortcodes. This is the recommended approach for most cases.

However, basic searches (using WordPress's standard `s` query param), will still render your theme's default search.php template (assuming there is one). You can redirect global searches to the page your shortcode lives on in the Settings. Go to **Settings &gt; Sitka Insights** and select **Redirect searches to a specific page**. Type the URI, e.g. `/search`, in the text box that appears.

Save your changes and you're good to go! Default searches will now redirect to your page. Note that all query string parameters will be preserved *except* `s`, which will be renamed to `sitka_search` to avoid conflicting with WordPress's default functionality.

#### Using the Sitka WordPress API directly

[](#using-the-sitka-wordpress-api-directly)

If you want a bit more control, you can use the provided WordPress API directly. Place something like the following in your theme at `search.php`:

```
// NOTE: the client may throw an exception!
use Swagger\Client\ApiException;

// Call out to the API
try {
  // search with some sensible defaults
  $response = Sitka\search();
} catch (ApiException $e) {
  error_log($e->getMessage());
  $response = [];
}

wp_header();

// Render results
