kimaai_embedding_render_mode

When it fires

Once per post in every sync of the knowledge base (the Sync tab, the automatic sync when a post is published or updated, wp kimaai vectors sync and the MCP re-embed tool), when its content is rendered to HTML. PDFs are read from the file instead and do not pass it.

With the_content, the default, KimaAI sets the post up as the global post and runs its content through WordPress’s the_content filter, as the page would: blocks, shortcodes and everything other plugins and the theme add there, such as share buttons or a related posts box. Any other value renders the raw content with do_blocks() and do_shortcode() only, without the the_content filter. A page builder that builds its output in the_content needs the default.

The HTML is cleaned (scripts, forms and the like removed) and turned into text after this. When a post’s text changes, its next sync embeds the changed chunks again.

Parameters

NameTypeDescription
modestringthe_content by default. Any other value renders the raw content with do_blocks() and do_shortcode() only.
postWP_Post|nullThe post being prepared for the knowledge base.
rawstringThe post’s raw content (post_content).

Returns

string: the_content, or another value such as blocks.

Example

add_filter(
  'kimaai_embedding_render_mode',
  function (string $mode, ?WP_Post $post): string {
    // Landing pages get sign-up boxes from other plugins through the_content: index only their own blocks.
    if ($post instanceof WP_Post && $post->post_type === 'landing_page') {
      return 'blocks';
    }

    return $mode;
  },
  10,
  2
);
  • kimaai_embedding_shortcode_blocklist: keeps a shortcode’s output out in either mode.
  • kimaai_embedding_remove_node_class_sets: removes elements of the rendered HTML by class.

What are your feelings