When it fires
Once per sync of the knowledge base, before it fetches the posts to index: a sync from the Sync tab, the automatic sync of a published or updated post, wp kimaai vectors sync and the MCP re-embed tool. The arguments already hold the post type, the IDs or the date the sync asked for; for PDFs the status inherit and the PDF MIME type.
KimaAI hooks it itself: it adds a meta_query clause that leaves out the PDFs whose “Include this document in the chatbot knowledge base” box is unchecked in the Media Library. Add to meta_query rather than replacing it.
A post the query leaves out is not synced, and its chunks from an earlier sync stay in the index. To keep a post out of the index and every answer, deny it with kimaai_content_access_tokens: the next sync then removes its chunks.
Parameters
| Name | Type | Description |
|---|---|---|
query_args | array | The WP_Query arguments; published posts without a password by default, newest first, at most the sync’s limit. |
args | array | What the sync asked for, with post_type, post_id, post_ids, limit and modified_after. |
Returns
array: The WP_Query arguments.
Example
add_filter(
'kimaai_embedding_fetch_query_args',
function (array $query_args): array {
// Posts with the custom field keep_out_of_chatbot are never synced.
$query_args['meta_query'][] = [
'key' => 'keep_out_of_chatbot',
'compare' => 'NOT EXISTS',
];
return $query_args;
}
);
Related
kimaai_embedding_supported_sources: the sources the Sync tab offers.kimaai_embedding_extra_text: adds text to the posts a sync indexes.