Docs

How markers work

W-Pencil finds editable values through invisible markers in the HTML. Who gets them, which values are marked for you and what the browser does with them.

5 min read WordPress 6.6+ Updated 1 Dec 2026

Why markers

Themes print values in every way WordPress allows: the_title(), a block, get_field(), an Elementor widget, a menu walker. Often there is no element to hang an attribute on. So W-Pencil wraps each editable value in invisible characters while the page renders, and the browser turns each pair into a link back to the exact place the value came from.

  • Open: U+2060, the target's number in base 3 (U+200B, U+200C and U+200D as digits), then U+2060.
  • Close: U+2060 U+2060.

The table that goes with them, from each key to its target and the field's label, is printed with the editor's settings in wPencilSettings.wPencil.t. A target looks like post/42/en/post_title/0/value: what holds the value, its ID, the language shown, the field, the item and the part (value, link or image). The browser only reads the part. The server works out the rest when a popup opens, and checks it again on every save.

Who gets them

Only people with Edit on the page (the w_pencil_use capability), and only on requests that are safe to mark. W-Pencil decides once per request, at template_redirect:

  • a logged-in user with Edit on the page;
  • a GET request for a page on the front end: not the admin, admin-ajax, the REST API, WP-Cron, a feed, an embed, robots.txt, a sitemap, a preview or the Customizer;
  • not a page builder's own editor or preview, such as Elementor's;
  • and only where they may edit the value. WordPress's own capabilities decide: edit_post for a page and its fields, edit_term for a term, edit_theme_options for menus and template parts, manage_options for the site's title and tagline, and each ACF options page's own capability.

Everyone else gets clean HTML, and so do WP-CLI, cron and anything that renders a page for someone else. Editors' pages are sent with nocache_headers() and DONOTCACHEPAGE, so a page cache never stores a marked page and never serves one to visitors.

Themes can switch marking off for a page with the w_pencil_active filter.

What is marked for you

Each mode marks what it owns, through WordPress's and the builders' own filters. Nothing needs theme work when the theme prints values the WordPress way:

  • The page's title, hand-written excerpt and featured image's alt text, printed with the_title() in the main loop, the Post Title block, the_excerpt() and the_post_thumbnail().
  • The site's title and tagline, wherever the theme prints them with bloginfo() or the Site Title and Site Tagline blocks.
  • Classic menus: each item's label, link and description, and menu names. Menus and the site title.
  • Gutenberg blocks: paragraphs, headings, lists, quotes, captions, buttons and images, synced patterns, template parts and navigation links. Gutenberg blocks.
  • ACF fields read with get_field(), the_field() and have_rows(), on pages, terms and options pages, rows of repeaters and flexible content, and ACF Blocks. ACF fields and blocks.
  • Elementor widgets' text, links and images, on pages and in templates. Elementor.

Fields are marked where they belong to the page's own post (or the term on a term archive), along with content the whole site shares, such as options pages, menus, template parts and the site's title. Lists of other posts, like a blog index or related posts, are left alone on purpose.

What stays unmarked

Markers are characters in the string, so W-Pencil keeps them out wherever a value leaves the page as something other than text:

  • <head> is buffered and cleaned: the <title>, meta tags and JSON-LD never carry markers.
  • Slugs and URLs: sanitize_title() and esc_url() drop them.
  • Trimmed text: wp_trim_words() drops them, and nothing in an automatic excerpt is marked.
  • Curly quotes: wptexturize() treats a marker as a space, so quotes still turn the right way.
  • The admin bar repeats the site's name and the page's title, and gets no pencils.

A value that would break if marked is never marked: an address, an email address, a number, or a slug like hello-world.

In the browser

For editors, W-Pencil's script runs first in the footer, before the theme's own scripts. It removes every marker from the page's text and attributes, and binds the text between each pair to its target.

  • Text: the run between a pair gets the outline and the pencil.
  • Attributes: a marker in alt makes the image editable, even when the alt text is empty, so every image gets its pencil. On an element with no text of its own, such as an icon link, a marked aria-label or title gets the pencil. Copies of a value in alt, title and aria-label elsewhere on the page are updated after a save.
  • Ignored: markers inside an element with the data-w-pencil-ignore attribute are removed but get no pencil. Use it for copies of content, such as a carousel's cloned slides.
  • Broken pairs: an open marker without its close, from a value that was cut short, is removed and never bound.
  • Added later: content a theme adds after the page loads is bound when the theme hands it to wPencilPlatform.attach(). Hooks and the toolbar shows how.

Nothing for visitors. Visitors load no W-Pencil script or style, and their HTML has no markers. Your theme's CSS can't reach the editor either: its toolbar and popups live in a shadow root.

Next in Themers

Hooks and the toolbar.

What a theme needs for W-Pencil, the filters for what the page shows after a save and where editing is on, values a theme prints itself, and the toolbar's CSS custom properties.