---
name: kimaai_embedding_source_title
type: filter
since: 1.4.9
tier: premium
feature: embeddings
area: embedding-search
summary: Changes the title a post or PDF has in the knowledge base, shown under answers as its source.
parameters:
  - name: title
    type: string
    description: The post's title, or the file name of an attachment without a title.
  - name: post
    type: WP_Post
    description: The post or attachment.
returns:
  type: string
  description: The title; an empty title becomes "(no title)".
---

# kimaai_embedding_source_title

## When it fires

When a post is prepared in a sync of the knowledge base, and when the Sync tab lists posts and indexed chunks. The title from the sync is stored with each chunk: the chatbot shows it under an answer as the source, and the AI reads it with the search result. The chunk's "Context:" line starts with it when the chunk is not under a heading.

A changed title reaches the index with the post's next sync, but only for the chunks whose text changed with it. A chunk under a heading does not contain the title, so a sync counts it as unchanged and it keeps the old one: after changing titles, run a forced sync (Force re-sync in the Sync tab, or `wp kimaai vectors sync --force`).

## Example

```php
add_filter(
  'kimaai_embedding_source_title',
  function (string $title, WP_Post $post): string {
    // Visitors see that a source opens a PDF.
    if ($post->post_type === 'attachment') {
      return 'PDF: ' . $title;
    }

    return $title;
  },
  10,
  2
);
```

## Related

- `kimaai_embedding_vector_metadata`: changes what is stored with each chunk, the title among it.
- `kimaai_embedding_supported_sources`: the sources a sync can index.
