Skip to main content

Post Documentation

Single Posts​

Structure and metadata for standard posts.

Research Papers​

Custom post type configurations and AI integration.

AI Generated Content​

Workflows for creating posts using tools like generate_articles.php.

Content with Repeated Images (ACF)​

For specific post types (like Kant L2 posts), images should not be embedded directly in the markdown content (e.g., ![Image](...)). Instead, they must be structured using the Advanced Custom Fields (ACF) repeater field.

  • Field Slug: content_with_repated_images (Note the intentional typo in "repated")
  • Field Key: field_695fa689053b3
  • Subfields:
    • content: The text chunk (WYSIWYG/HTML).
    • image: The Attachment ID of the image.

Workflow for updating via script:

  1. Upload the image to the WordPress media library to get the Attachment ID.
  2. Prepare the text chunk (use nl2p_preserve() or similar to maintain paragraph formatting).
  3. Use update_field('field_695fa689053b3', $repeater_data, $post_id) to save the structured data.
  4. If update_field returns false (which can happen if ACF thinks the data hasn't changed or due to serialization quirks), verify the update by querying the database directly:
    wp db query "SELECT LENGTH(meta_value) FROM wp_postmeta WHERE post_id = <ID> AND meta_key LIKE 'content_with_repated_images_%_content'"
  5. Always run wp cache flush after updating post meta.

CSS and Styling for L1/L0 Content​

Historically, styles for L1 and L0 content were pushed into the _wpb_post_custom_css meta field via SQL/regex scripts. This approach was flawed and resulted in corrupted CSS strings in the database that broke browser parsing.

Current Architecture:

  1. Static Files: All custom CSS for L1 and L0 content is organized into static template files located in /wp-content/plugins/posts-ai-chatboxes/public/css/templates/ (e.g., pac-l1-styles.css, pac-l0-german.css, pac-l0-english.css).
  2. Enqueueing: These files are dynamically enqueued by posts-ai-chatboxes.php.
  3. HTML Structure: L1 content generated by the plugin is wrapped in a <div class="pac-child-content"> to ensure proper scoping for the loaded styles.

Kant Suite Multi-Layer Architecture Constraints​

When creating or updating a "Kant Suite" (usually 1 L2 parent, 1 L1 bridge, and 3 L0 sources), you must adhere to the following strict database architectural rules to prevent frontend DOM and layout breakage:

L2 (The Narrative Layer)​

  • Storage: Narrative text blocks and images must sit exclusively inside the ACF content_with_repated_images repeater rows.
  • Crucial Rule: The standard post_content field must be left entirely empty. Injecting the narrative text into post_content alongside the ACF repeater array will cause the WordPress frontend template to double-render the content sequentially.

L1 (The Bridge Layer)​

  • Storage: Educational breakdowns and synced section anchors (<div id="..." class="sync-section">) must live exclusively inside the native post_content field.
  • Crucial Rule: The content_with_repated_images ACF repeater field must not exist on the L1 DB entry.
  • Required Wrapper: Everything must be nested in <div class="kant-content">.

L0 (The Source Layers - German A, German B, English)​

  • Count: Every L1 post must parent exactly three L0 nodes.
  • Multi-panel Scrolling Bounds: The layout heavily relies on dispaly: flex; vertical alignments using strictly enforced sibling tags.
  • Line Markers: Every logical line must be broken explicitly: <span class="lnum" data-lnum="06"></span><span class="ltext">...</span>.
  • Span Closures: Text highlights (<span class="pencil-dashed">) must never span across line numbers. They must terminate at the end of the line, and reopen cleanly on the next line using .mark-cont.