Tutorial: Using Site Layout

Site Layout is where you build a visual, dynamic template for single posts, pages, archives, 404, or search results — using the same Page Builder canvas you already use for regular Pages, but with widgets that pull their content from whatever post WordPress is currently displaying instead of content you type in manually.

For the full architecture reference, see Site Layout. This tutorial covers the day-to-day workflow: creating an entry, adding dynamic widgets, and assigning it.


Creating a Site Layout Entry

  1. Go to WordPress Admin → Sanil Builder → Site Layout.
  2. Click Add New.
  3. Give it a descriptive title (e.g. "Default Archive Layout") — this title is only for your own reference in the admin list; it is never shown to site visitors.
  4. The Page Builder metabox appears below the title field, exactly like it does on a regular Page. Build your layout using sections, rows, columns, and widgets as usual.

Adding Dynamic Widgets

Alongside every normal Page Builder widget (Heading, Paragraph, Image, Posts, …), the widget picker includes five dynamic widgets that resolve against whatever post WordPress's current loop/query has in scope, rather than content you type in:

Widget Resolves to
Post Title get_the_title() of the current post
Archive Title get_the_archive_title() — the category/tag/date/author/post-type label
Featured Image The current post's featured image, same helper the Posts widget uses
Post Content The current post's full content, run through the same filter chain the_content() uses
Excerpt The current post's excerpt, with an optional word-count override

None of these have a text field to fill in — there is nothing to type, because the content is never fixed. Drop one in, style it (tag, color, typography, alignment — see Page Builder → Typography Fields), and save.

Why widgets look empty while you're editing

While you're building a Site Layout entry, the canvas previews widgets against the entry itself — not against a real post — because there is no "real post" yet; you're authoring a template that will apply to many different posts later. The entry you're editing has a title (whatever you named it in step 3 above) but no real excerpt, content, or featured image, so Excerpt/Post Content/Featured Image will show a dashed placeholder box instead of a blank one while you edit. This is expected — it only appears in the admin editor, never on the live site. See Site Layout → Editing against a Site Layout entry's own ambient context for why.


Assigning the Entry to a Content Type

In the Applies To box in the right sidebar (same area as Publish/Categories on a normal post):

  1. Choose which content type this layout is for: Single Post, Page, Archive, 404, or Search Results.
  2. Click Publish (or Update if already published).

That's it — as soon as it's published with a type selected, it becomes the active layout for that type, immediately, for every visitor. There's no separate "activate" step.

Only one entry can be active per type. If you create a second entry and assign it to the same type, it replaces the first as the active one. The first entry keeps its own "Applies To" selection showing (so it still looks assigned when you open it), but it's no longer the one actually rendering — only the option value, not the dropdown state, decides which entry is live.

To unassign a type (fall back to the theme's default template for it), open the active entry and change Applies To back to "— Not assigned —", then update.


Verifying It Worked

Visit a real post/page/archive/404/search-results URL matching the type you assigned. You should see your Site Layout entry's design, with dynamic widgets showing that specific page's real title/content/excerpt/image — not the placeholder box you saw while editing.

If nothing changed on the frontend:

  • Confirm the entry is published, not a draft — unpublished entries are treated as "not assigned" and the theme's default template renders instead.
  • Confirm you selected the right type in Applies To and clicked Update after changing it.
  • For archive-type entries, confirm each item in the loop shows different data per card (not all cards repeating the first post) — if every card looks identical, something is preventing the loop from advancing; check for PHP errors in the debug log.

Common Mistakes

A dynamic widget shows nothing on the live frontend

This can be legitimate: a 404 page has no post at all, so Post Title/Excerpt/etc. correctly render nothing there. On a real single/page/archive item, an empty Excerpt or Post Content usually means that specific post genuinely has no content/excerpt set — not a bug in the widget.

Two entries both show "Archive" selected in Applies To, and I'm not sure which is live

Only one is. Check wp_options for sanilwb_layout_assignment_archive (or ask a developer to check) — its value is the post ID of the entry that's actually rendering.

I deleted/trashed the active entry and the site broke

It shouldn't — a trashed or deleted entry is treated the same as "nothing assigned," and the type falls back to the theme's own hard-coded default template for it (partials/site-layout-defaults/{type}.php). There's always a fallback for these five types; only header/footer still depend on a configured preset (see Header & Footer).