kimaai_embedding_extra_text

When it fires

Once per post in every sync of the knowledge base, after the post’s text was extracted (from its rendered content, or from the file for a PDF) and before it is split into chunks. What the filter returns is appended to the text after a blank line and is indexed with it: it can be found, it is quoted as a source, and the AI reads it.

KimaAI hooks it itself at priority 10 for the content templates (Embedding, Content templates), which write custom fields, taxonomies and ACF fields into the text per post type. Add to $text instead of replacing it, or their text is lost.

The post’s chunks are embedded again on its next sync when the added text changed.

Parameters

NameTypeDescription
textstringText appended to the post’s text; empty unless a content template added some.
postWP_PostThe post being prepared for the knowledge base.

Returns

string: The text to append.

Example

add_filter(
  'kimaai_embedding_extra_text',
  function (string $text, WP_Post $post): string {
    if ($post->post_type !== 'product') {
      return $text;
    }

    // The delivery time is a custom field the product page shows outside the content.
    $delivery = (string) get_post_meta($post->ID, 'delivery_time', true);
    if ($delivery === '') {
      return $text;
    }

    return trim($text . "\n\nDelivery time: " . $delivery);
  },
  10,
  2
);
  • kimaai_embedding_chunk_text: changes what is embedded per chunk, without changing the stored text.
  • kimaai_embedding_vector_metadata: stores data with each chunk instead of in its text.

What are your feelings