WordPress Plugin
Although Findkit can work with any website without any Findkit specific code, we have also developed a WordPress plugin to make it easier for WordPress users to integrate Findkit. The plugin is avaible on the WordPress Plugin Directory and Github
The plugin extends the WordPress admin interface and exposes a PHP API. This documentation focuses on the PHP API. For more information on the WordPress admin extensions read this page.
The PHP API enables following use cases:
- Use WordPress filters to modify the generated meta tag
- Control the live updates using filters
- Private search results for logged in users using JWT
- Start crawls
- Server-side search
- Expose the PHP API to AI agents and other tools as WordPress Abilities
Functions
Following global functions are available when the plugin is active
findkit_search($terms, $search_params, $options)
Make server-side search request
Args
$terms: string: Search terms$search_params: array: Search params like in the UI Library$options?: array: OptionspublicToken: string: The project public token. If not defined read from thefindkit_project_idoption
Returns Array
Example return value
[
'total' => 1,
'duration' => 7,
'hits' => [
[
'score' => 65.79195,
'superwordsMatch' => false,
'title' => 'How Findkit Scores Search Results?',
'language' => 'en',
'url' =>
'https://www.findkit.com/how-findkit-scores-search-results/',
'highlight' =>
'But what is an index and <em>how</em> the pages are <em>scored</em> when searching?',
'tags' => [
'wordpress',
'domain/www.findkit.com/wordpress',
'wp_blog_name/findkit',
'domain/www.findkit.com/wp_blog_name/findkit',
'public',
'wp_post_type/post',
'domain/www.findkit.com/wp_post_type/post',
'domain/www.findkit.com/wp_taxonomy/category/article',
'wp_taxonomy/category/article',
'domain/www.findkit.com',
'domain/findkit.com',
'language/en',
],
'created' => '2024-05-20T07:44:47.000Z',
'modified' => '2024-05-20T10:49:11.000Z',
'customFields' => [
'wpPostId' => 34,
'author' => [
'type' => 'keyword',
'value' => 'Esa-Matti Suuronen',
],
'excerpt' => [
'type' => 'keyword',
'value' =>
'Findkit is crawler based search toolkit which stores web pages to a search index. But what is an index and how the pages are scored when searching?',
],
],
],
],
]
Example
findkit_search('test', [
'filter' => [
// Limit results to example.com domain
'tags' => ['domain/example.com']
]
]);
findkit_search_groups($terms, $groups, $options)
Make multiple server-side search requests using a single request.
Args
$terms: string: Search terms$groups: array: Array of search params like in the UI Library$options?: array: OptionspublicToken: string: The project public token. If not defined read from thefindkit_project_idoption
Returns Array
Example return value
[
'duration' => 32,
'groups' => [
[
'total' => 1,
'duration' => 7,
'hits' => [
[
'score' => 65.79195,
'superwordsMatch' => false,
'title' => 'How Findkit Scores Search Results?',
'language' => 'en',
'url' =>
'https://www.findkit.com/how-findkit-scores-search-results/',
'highlight' =>
'But what is an index and <em>how</em> the pages are <em>scored</em> when searching?',
'tags' => [
'wordpress',
'domain/www.findkit.com/wordpress',
'wp_blog_name/findkit',
'domain/www.findkit.com/wp_blog_name/findkit',
'public',
'wp_post_type/post',
'domain/www.findkit.com/wp_post_type/post',
'domain/www.findkit.com/wp_taxonomy/category/article',
'wp_taxonomy/category/article',
'domain/www.findkit.com',
'domain/findkit.com',
'language/en',
],
'created' => '2024-05-20T07:44:47.000Z',
'modified' => '2024-05-20T10:49:11.000Z',
'customFields' => [
'wpPostId' => 34,
'author' => [
'type' => 'keyword',
'value' => 'Esa-Matti Suuronen',
],
'excerpt' => [
'type' => 'keyword',
'value' =>
'Findkit is crawler based search toolkit which stores web pages to a search index. But what is an index and how the pages are scored when searching?',
],
],
],
],
],
],
];
Example
findkit_search_groups('test', [
[
'filter' => [
'tags' => ['domain/example.com']
]
],
[
'filter' => [
'tags' => ['domain/other.example.com']
]
]
]);
findkit_full_crawl()
Start a full crawl. Findkit API key must be configured the wp-admin.
findkit_manual_crawl($urls)
Start a manual crawl. Findkit API key must be configured the wp-admin.
Args
$urls: array: Array of URLs (strings) to crawl
findkit_partial_crawl()
Start a partial crawl. Findkit API key must be configured the wp-admin.
findkit_delete_pages($urls)
Delete pages from the search index by their exact urls, without crawling them. Use this to remove pages that no longer exist or have moved. Findkit API key must be configured in the wp-admin.
Args
$urls: array: Array of URLs (strings) to delete, at most 50 per call
findkit_get_link_report($options): array
Get the links on the site which point at pages that are missing, forbidden,
failing or redirected. Built from data collected during the crawl, so it sends
no requests to the site. Requires track_links =
"all" on the crawler target, which is a Pro plan
feature.
Args
$options: array:targetto limit to a single crawler target host,limitfor how many links to return (1-5000, defaults to 1000) andrefreshto skip the 15 minute cache
The response is documented with the findkit/link-report
ability.
findkit_get_page_meta($post): array
Get the Findkit Page Meta for a post object.
Returns Array
Example return value
[
'showInSearch' => 1,
'title' => 'How Findkit Scores Search Results?',
'created' => '2024-05-20T10:44:47+03:00',
'modified' => '2024-08-15T14:19:34+03:00',
'customFields' => [
'wpPostId' => [
'type' => 'number',
'value' => 1185
],
'excerpt' => [
'type' => 'keyword',
'value' => 'Findkit is crawler based search toolkit which stores web pages to a search index. But what is an index and how the pages are scored when searching? Lets take a look. In short index is a mapping in a database of every word on every page to the page URLs where the words are seen. […]'
],
'author' => [
'type' => 'keyword',
'value' => 'Esa-Matti Suuronen'
]
],
'language' => 'en',
'tags' => [
'wordpress',
'domain/www.findkit.com/wordpress',
'wp_blog_name/findkit',
'domain/www.findkit.com/wp_blog_name/findkit',
'public',
'wp_post_type/post',
'domain/www.findkit.com/wp_post_type/post',
'domain/www.findkit.com/wp_taxonomy/category/article',
'wp_taxonomy/category/article'
]
]
Filters
Filters for add_filter
findkit_page_meta
Filter the Findkit Page Meta for a post object.
Callback parameters
$meta: array: The Findkit Page Meta$post: object: The post object
Following fields are automatically added to the $meta array:
showInSearch: Archive pages are automatically excludedtitle: Clean page titlecreated: Created timemodified: Modified timelanguage: Language from the post or Polylangtags: Some basic tags including public taxonomies
Example
add_filter('findkit_page_meta', function ($meta, $post) {
$meta['title'] = 'My custom title';
return $meta;
}, 10, 2);
findkit_sidebar_post_types
For which post types to enable the Findkit sidebar.
Callback parameters
$post_types: array: Post types- Default:
['post', 'page']
- Default:
findkit_can_live_update_post
Whether to allow live updates for a post
Callback parameters
$can: bool: Can live update- Defaults to
trueon webfalseon CLI
- Defaults to
$post: object: The post object
findkit_allow_jwt
Allow JWT search authentication. This allows customizations on who can use the search. See the JWT docs for more information.
Callback parameters
$allow: bool: Allow JWT- Default:
truewhen a user is logged in
- Default: